0

When running my Angular app locally I can go to for example localhost:4200/login. When I deploy my Angular app however when I go to website.com/login, I get "The requested URL /login was not found on this server". My app is deployed to a Google Cloud appengine.

When I add "useHash: true" to my RouterModule. It works fine, so website.com/#/login works, however this seems counterintuitive since when someone would fill in the url themselves I would assume that they would fill in website.com/login, which would redirect them again to the not found on this server.

How can I avoid using this "useHash:true" and have my routing the same as being locally?

Babhoster
  • 63
  • 6
  • have you tried solutions mentioned in this ans https://stackoverflow.com/questions/43535048/angular-2-routing-does-not-work-when-deployed-to-http-server – Barkha Apr 11 '20 at 22:03
  • Tried all solutions mentioned there. Also deleted cache every re-upload, nothing worked. The only thing that works is when I leave "useHash: true" in it. – Babhoster Apr 12 '20 at 14:24

1 Answers1

2

I assume your app.yaml would look something like this:

handlers:
  - url: /
    upload: /index.html
    static_files: /index.html
    secure: always

now when you try to open the URL /login/, there's no route for it in app.yaml, which is why it returns you 404. So the useHash directive is the only solution you have here.

yedpodtrzitko
  • 8,323
  • 2
  • 36
  • 39