0

We have an angular app hosted at the root of a domain, say: example.com

We have a mvc.net api running at the /api virtual directory: example.com/api

We have rewrite rules in our api's web.config to allow calls to /api, and this is working correctly because our xhr calls are working.

For authentication, we have to route the browser to example.com/api/auth/whatever so it can then appropriately 302 to an authentication provider. Once the user authenticates, they are routed back to our API, and then back to the angular application.

This all works without issue in development, because everything is technically in separate domains (locahost:4200, 4201, etc). Once it's deployed on the same domain, the angular router then starts intercepting the auth link clicks, and routing to the catch all route once no routes match.

I've tried adding target="_self" to the links, as I've seen others recommend, but that has not changed the behavior.

Is there a way to force angular to not process a route, or provide some guard that would intercept the route, and just let the browser handle it?

aasukisuki
  • 1,186
  • 1
  • 11
  • 33

1 Answers1

0

I was able to figure this out with the help of chrome dev tools, and this stackoverflow post

We are using the angular pwa package, and I had looked over that network log showing that the service worker was serving the URL from the cache (in this case, incorrectly). We've added the following entry into ngsw.json:

  "dataGroups":[
    {
      "name": "api",
      "urls": ["/api"],
      "cacheConfig": {
        "maxSize": 0,
        "maxAge": "0u",
        "strategy": "freshness"
      }
    }
  ]

and now all api calls are no longer cached. We may further refine this to just our auth urls, but this is working for now.

aasukisuki
  • 1,186
  • 1
  • 11
  • 33