2

I have an Angular application I've deployed to an IIS web application at my-machine:8111/my-app. I've set both the base tag and the APP_BASE_HREF value mentioned in this answer to the absolute URL for the app: https://my-machine:8111/my-app/.

For some reason, when I initially load the application—when I hit that absolute URL—I get an error:

Error: Cannot match any routes. URL Segment: 'my-app'

I don't know why the web application name is being read as part of the Angular route. I'm sure the base URL is correct: If I take of the last slash or try a relative path I can't even load the application.

Why isn't it routing to /? How can I fix it?

ricksmt
  • 888
  • 2
  • 13
  • 34

1 Answers1

3

APP_BASE_HREF is used in the following manner: {{host}}:{{port}}{{APP_BASE_HREF}}, and with your APP_BASE_HREF set to the full string "https://my-machine:8111/my-app/" it's expecting that to be appended into the {{APP...}} section. It only wants the part after {{host}}:{{port}} since those two items are handled by your server already.

Setting APP_BASE_HREF to "/my-app" will solve the current problem, but your IIS server may require addition tuning such as route-parameter forwarding before your app is 100% functional.

Z. Bagley
  • 8,942
  • 1
  • 40
  • 52
  • You were right. I took a closer look at what was happening, and `/my-app/` was getting expanded like a path. The final solution was to do `//my-app\\', and then it would convert to `/my-app/`. – ricksmt Sep 11 '17 at 17:19