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

Router doesn't function properly with custom base path #834

Closed
djvaldez opened this issue Apr 25, 2023 · 0 comments · Fixed by #889
Closed

Router doesn't function properly with custom base path #834

djvaldez opened this issue Apr 25, 2023 · 0 comments · Fixed by #889
Labels
bug Something isn't working high priority UI Related to the frontend web ui written in Javascript
Projects

Comments

@djvaldez
Copy link
Contributor

Describe the bug
When building the app with a custom base path, either through the Docker UI_PUBLIC_URL arg or the NPM build flag directly, no pages in the UI load properly. Instead, every page will get routed to the NotFoundPage.

To Reproduce
Steps to reproduce the behavior:

  1. Run the app with a custom base path of photoview with the right Docker Compose and NGINX configs:
# Modify the Dockerfile photoview config to build locally for a custom path, e.g:
photoview:
  build:
    context: .
    args:
      - UI_PUBLIC_URL=/photoview/
      - REACT_APP_API_ENDPOINT=https://djv.ddns.net/photoview/api
# An example nginx config for a server to redirect custom base path
set $photoview 127.0.0.1;

location /photoview {
  return 302 $scheme://$host/photoview/;
}

location /photoview/ {
  # Rewrite to strip /photoview from URL path
  rewrite ^/photoview/?(.*)$ /$1 break;
  proxy_pass http://$photoview:8444;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header Host $host;
  proxy_http_version 1.1;    # to keep alive
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
}
  1. Navigate to the app being served at your url: http://my-server/photoview
  2. Observe that the page displays "Page not found", indicating that it's routing to NotFoundPage
  3. Check the network tab; you'll see that there is no request for the LoginPage component

Expected behavior
The app should first properly redirect to and load the login page

Screenshots
Screenshot 2023-04-24 at 9 57 13 PM

Your environment:
Feel free to remove and add what you think might be useful.

Additional context
One solution to this is to modify the Router component to use the configured base path:

<Router basename={import.meta.env.BASE_URL}>
@djvaldez djvaldez added the bug Something isn't working label Apr 25, 2023
@kkovaletp kkovaletp added this to To do in Roadmap via automation May 3, 2024
@kkovaletp kkovaletp linked a pull request May 3, 2024 that will close this issue
@kkovaletp kkovaletp added UI Related to the frontend web ui written in Javascript high priority labels May 3, 2024
Roadmap automation moved this from To do to Done May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority UI Related to the frontend web ui written in Javascript
Projects
Development

Successfully merging a pull request may close this issue.

2 participants