supertokens / supertokens-web-js

SuperTokens SDK for vanilla JS for all recipes
Other
58 stars 10 forks source link

Issues with Angular guide #66

Closed mengnans closed 2 years ago

mengnans commented 2 years ago

First of all, I have to say thanks to this package, we all very much in love with supertokens.

We are having some troubles when setting up supertokens with our Angular project.

  1. For Angular, we are not using Axios, but ticking no to the question below

image We are getting a message says:

When using fetch, network interceptors are added automatically when you call supertokens.init. So no action needed here.

However, under the hood Angular isn't using fetch, I reckon it's using httpClient (Correct me I am wrong, as I am pretty much new to Angular). So our Angular request isn't setting withCredential to true. We kinda fix it by doing this:

image

  1. For Angular, after I have successfully logged out, all other cookies are removed correctly, but the sIRTFrontend cookie is set to "Remove". I believe it's messing up the next login. Cuz if I login again, and refresh the page, all other cookies will be removed. We are getting away from it by removing that cookie every time before sign in.

FYI, we are not facing above issues with the React solution.

Thanks in advance.

rishabhpoddar commented 2 years ago

Hey! this is a known issue, and we are working on supporting HttpClient by adding interceptors to XMLHttpRequest. This has not been released yet, but feel free to use it:

npm i git+https://github.com:supertokens/supertokens-website.git#xmlhttprequest-interception

You no longer need to add axios interceptors - using HttpClient should just work after calling supertokens.init.

Keeping this issue open until we release this.

mengnans commented 2 years ago

Thanks a lot @rishabhpoddar

rishabhpoddar commented 2 years ago

We now support XHR interception in version >= 0.3.0, therefore Angular httpClient should work out of the box.