Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use a wger instance running on a sub-url #193

Closed
kovdan01 opened this issue Jun 25, 2022 · 9 comments · Fixed by #192
Closed

Can't use a wger instance running on a sub-url #193

kovdan01 opened this issue Jun 25, 2022 · 9 comments · Fixed by #192

Comments

@kovdan01
Copy link
Contributor

Steps to Reproduce

  1. Install a wger instance at a sub-url, like https://example.com/wger. I keep in mind that such type of installation is discouraged, but I'm OK with it for my personal usage.
  2. Try to login via mobile app.
  3. Get FormatException: Unexpected character (at character 1) <!DOCTYPE HTML PUBLIC ....

Expected results:

Successful login.

Actual results:

A FormatException error message.

Investigation

I inspected my Apache 2 webserver logs and it turns out that the mobile app just removes sub-url (tries to access server.name/api/v2/login instead of server.name/wger/api/v2/login) and that's why gets error 404 instead of a json with a response. To fix the problem, we need to alter makeUri function (see https://github.com/wger-project/flutter/blob/master/lib/providers/helpers.dart#L20). I'm not a flutter developer, I don't know Dart and I don't have time to setup a development environment, but I suppose that the following fix should work:

 ]) {
   final Uri uriServer = Uri.parse(serverUrl);
 
-  final pathList = ['api', 'v2', path];
+  final pathList = [uriServer.path, 'api', 'v2', path];
   if (id != null) {
     pathList.add(id.toString());
   }

Created a PR #192. @rolandgeider Please consider reviewing and merging it. Thanks!

@rolandgeider
Copy link
Member

Hi! Yes, this is a use case that was never tested, so I'm not surprised it breaks stuff (does the regular web app work fine on a sub path?). I'll try to setup this these days

@kovdan01
Copy link
Contributor Author

does the regular web app work fine on a sub path?

I was able to login as admin and change password. Did not tested the app extensively, but suppose that everything is OK - at least, I've ensured that links point to correct URLs (including sub-url). The only issue that I have noticed - after login you are redirected to clear domain URL instead of sub-url.

I'll try to setup this these days

Thanks!

@rolandgeider rolandgeider linked a pull request Jul 18, 2022 that will close this issue
@rolandgeider
Copy link
Member

Closed with #192

@gregflynn
Copy link

hate to necro bump but I'm getting this same error but with a subdomain'd server. Web interface works great just can't login to the mobile app. Happy to create a separate issue but wanted to ping here first.

@rolandgeider
Copy link
Member

hi @gregflynn , a subdomain should make even less problems. What error are you getting?

@rolandgeider
Copy link
Member

oh wait, you can't login with the mobile app, I think I know what that is

@gregflynn
Copy link

hi @gregflynn , a subdomain should make even less problems. What error are you getting?

Same steps to reproduce as this issue with the difference being https://foo.example.com as opposed to https://example.com/foo

oh wait, you can't login with the mobile app, I think I know what that is

Awesome, I looked at the PR for resolving this original issue and would have though it would have resolved this subdomain issue too

@rolandgeider
Copy link
Member

so I think we broke the app login with the new brute force login detection (wger-project/wger#1163), but you can just disable that by setting AXES_ENABLED=False

@gregflynn
Copy link

so I think we broke the app login with the new brute force login detection (wger-project/wger#1163), but you can just disable that by setting AXES_ENABLED=False

Confirmed! Will take discussion there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants