Auth0 provides the AuthHttpInterceptor to automatically attach a Bearer token to an outgoing HTTP request. You can set up the interceptor to match specific route URL’s in the App.Module by doing the following:
Just to clarify, are you wanting to send an Access Token with every request that follows the pattern of http://localhost:5050/api/* (for example, http://localhost:5050/api/123 or http://localhost:5050/api/abc456), but not allow something like http://localhost:5050/api/*/some-other-url-param (for example, http://localhost:5050/api/abc456/profile)?
Unfortunately, I don’t believe there is a way to configure an allowedList with anything but hard-coded URLs or a wildcard at the end of the URL, but I can double-check if this sounds like what you are looking for.
I’m also implementing this in my angular10 web app.
But for some reason it doesn’t work. It doesn’t apply the interceptor for my requests.
I have followed the setup here.
So this for my localhost dev setup that uses CORS and I’m not sure if that interferes with HTTPInterceptor as well. Will do more research on my end and will try a build that runs from the same-origin to avoid CORS.
I’m using "@auth0/auth0-angular": "^1.3.2", version. Any ideas what could cause this?
Unfortunately, the allowedList property only supports a wildcard at the end of the URL as I suspected. If you’d like to see the support of more complex patterns, it would be great to get your feedback and details of your use-case in our feedback category: