<@498057949541826571> I am using wundergraph to send a request to getself endpoint protected by supe...
a
@rp_st I am using wundergraph to send a request to getself endpoint protected by supertokens. But I am getting this response. Can you please help:
p
hi
this is the expected response if the access token expired for example
you can enable debug logs to check why you are getting this response: https://supertokens.com/docs/emailpassword/troubleshooting/how-to-troubleshoot#enable-backend-logs
it outputs a fair bit of information, but I'm happy to help parse it 🙂
a
Seems wundergraph is not atatching cookies with the request
Copy code
--- DebugTransport ---

Request:

GET /account/getme HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json



Duration: 18 ms

Response:

HTTP/1.1 401 Unauthorized
Content-Length: 26
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:3000
Content-Type: application/json; charset=utf-8
Date: Thu, 13 Oct 2022 23:53:30 GMT
Traceparent: 00-1e51dc85a26af12d59ba23b2d6238383-c36f0e1e7d8874cf-01

{"message":"unauthorised"}

--- DebugTransport
Here are backend logs
r
Have you added our interceptors when making the request?
a
I think https://supertokens.com/docs/passwordless/nextjs/init#8-add-api-interceptors-for-automatic-session-refreshing is not implemented. Prior to using wundergraph I skipped step 8 and everything was working. @rp_st can you provide code samples with wundergraph
r
does wondergraph use fetch underneath? Or axios? Or does it allow you to provide a custom network lib to use? Does it use XHR? One way to find out easily is to see on network tab on chrome when a request is made - the row in the network tab will have
fetch
or
xhr
written on it
a
fetch believe
r
Hmm. And have you called Supertokens.init before?
Maybe enable frontend debug logs and show me the output
So the value of apiDomain is set to localhost:8080, but you are querying localhost:9991
Which is why interception is not being done
a
ok let me change
Should I change it in backend sdk too?
r
yes
a
no luck
r
so interception is happening now. Can you send be backend debug logs please for the API call?
a
and here are the logs wundergraph generate
r
can you relogin and show me the set-cookie header in the response of the login API? A screenshot will do
a
logs from frontend
?
r
no.
login
and in the signin API response headers, you will see set-cookie headers
can you take a screenshot of those and show me the output
a
ok
i am getting this
probably changed the port to 9991
let me cahnge it back to 8080 and login
r
well, if you change it back to 8080, it won't work with the other server
a
I was not able to take screenshot as login was fast
Will this help
I fixed it. thanks for help
r
Oh! How did you fix it?
a
Actually supertokes was working fine. Wundergraph clean swiped all the header from the request when sending to the server so. I have to explicitly allow cookie header to pass through wundergraph
In wundergraph.config.ts I added this
Copy code
baseURL: "http://localhost:8080",
headers: (builder) => builder.addClientRequestHeader("cookie", "cookie"),