mozilla-ai / lumigator

Source code for Mozilla.ai's Lumigator platform
https://mozilla-ai.github.io/lumigator/
Apache License 2.0
63 stars 7 forks source link

Frontend: support single page apps (SPA) when served with nginx #420

Closed peteski22 closed 8 hours ago

peteski22 commented 1 day ago

What's changing

Our frontend operates as a single page application (SPA), and we create a container to host it using nginx when we make local-up or make start-build-lumigator.

When using the app, the URL bar appears to show different paths (/datasets, /experiments) but they're all hosted from the same place. However, nginx doesn't know this and so if you attempt to browse directly to a page (rather than the root), or refresh a page you get a 404 not found.

This PR changes the default nginx daemon config so that it will reroute requests to the root index page. In order to add the single line:

try_files $uri $uri/ /index.html;

We need to supply the entire config file, as such we now have a copy of the default.conf modified that is copied by Docker.

How to test it

Additional notes for reviewers

http://localhost/experiments

Before:

image

After:

image

To check the default config file you can exec into a container then:

cat /etc/nginx/conf.d/default.conf

I already...