-
Notifications
You must be signed in to change notification settings - Fork 77
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
Heroku and EB deep links not routing #16
Comments
There are technically two applications in this repository. One is for the backend which serves to static content or HTML, and the Angular portion of the app is only on the front-end. So I deployed the backend to Heroku (https://angular2-login-seed.herokuapp.com/api/....), and the front-end app is just in the gh-pages branch of this repository. When you visit https://domfarolino.com/angular2-login-seed you're hitting the static front-end angular app, and whenever the angular app needs some data to display on the page it hits the API deployed on Heroku. This make sense? The front and back end are completely divorced, so the deep linking/routing is all done with the Angular app in the front-end. |
It is possible to deploy them all with one app, but it is messier. You'd need the backend application to serve the same HTML file for any route that does not start with /api/ so that the Angular router could actually handle each route itself (and not let the backend serve some nonesense), and furthermore you'd need to be serving the index from the dist/ folder that contains the compiled version of the angular app. When creating a robust single page app in something like Angular it makes sense to let Angular (with all its features and glory etc) handle just about everything except for dynamic data collection, which is what the backend does in this application. So when you deploy to Heroku you should only be deploying the back-end app, now you can serve the front-end from anywhere and just make sure the Angular app hits the correct back-end. Let me know if you need any more info/help |
Totally, I get that we have the Angular app and api app. I'm having trouble with the Angular app right now. |
Hmm, could you give me the URL you're hosting the Angular app at? |
Here we are Here are the reproduction steps
Expected - the login screen should display correctly I haven't enabled cors so none of the api calls will work. |
Thanks for the information. Fast forward to us refreshing the page after the URL changed on the front-end. Now we're actually saying, "hey server - serve us up the content at Regarding http-server, I've never used it so I don't know if there's a way to say "hey server, on request of Does this make sense why the deep-linking is failing? It is nothing to do with the Angular app, it is instead a fundamental issue that very watered-down basic http servers have when trying to serve single-page applications with routers built in. The idea is typically we want to serve the same static content no matter what request is made, and sometimes baking those rules into the server is simple. |
For example when I try to retrieve
Because we've got no rule telling the server to route everything to |
I'll try the nginx routing again. Thanks for the help! |
I can't get the deep links to work when I'm hosting the application on Heroku/EB.
I've tried to run an nginx server to route everything to the index.html in ./dist but the deep links are still not found.
Can you run through how you hosted the project on Heroku?
The text was updated successfully, but these errors were encountered: