angular2-jwt: 1.0.0-beta.10: Failed to construct 'URL': Invalid URL
with beta 9 everything was working fine but with beta10 i get now:
Failed to construct ‘URL’: Invalid URL
url example:
/api/v1/system/mode
(same server)
JwtModule.forRoot({
config: {
tokenGetter: tokenGetter,
whitelistedDomains: ['localhost']
}
}),
export function tokenGetter() {
return localStorage.getItem(Configuration.AUTH_TOKEN_ID);
}
This issue is caused by the changes on src/jwt.interceptor.ts in pull request #438
const requestUrl = new URL(request.url);
will not accept relative urls. It has to be new URL(relative, base)
or new URL(full-url)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 28
- Comments: 30 (4 by maintainers)
Hi everybody,
I was dealing with exactly the same issue after updating to 1.0.0, even if I was already using absolute URLs in all of my requests. After investigating, I realized that the problem was coming from the custom factory of the translation package TranslateModule.
And this is how I fixed it.
Hope this will be helpful!
Same problem with release 1.0.0
There are also cases where it’s impossible to know the full URL in advance (the final prod host name is unknown at development time). I think the library has to allow for relative URLs.
Same problem with release 1.0.0 😦
Same issue here.
Sample URL: “./assets/i18n/en.json”
Confirmed. Solved with 1.1.0.
Same issue 😦
Meanwhile I had to do a downgrade to 1.0.0-beta.9 version.
@Sambaja we are using this library under {N}ativeScript on iOS / Android. I’d prefer the fix in #489 if possible.