I am working on a rails api (no views) app with angular 5 as front-end. Both frameworks are integrated in the same project following the structure proposed namely here.
The application is deployed on Heroku. The first page of the app is e.g. example.com/home
. When I refresh the page in the browser, the page did not display anymore and I get a 404 error in the browser. Same for links from emails.
There is indeed no rails route for /home
as this is a angular route.
I found this anwser that is refeering to this angular doc stating that a fallback routing to index.html
has to be setup on the web server to handle linking from emails, external sources or refreshing pages.
I did the test on a local install with nginx. By default the refresh yields a 404 error but adding the rule in the config file:
try_files $uri $uri/ /index.html;
solve the issue.
How can I achieve this on Heroku?