React Native and Fetch via Server API in nextjs - 401 Unauthorized error #27909
Labels
bug
Something isn't working
external-issue
needs-analysis
Issue status is unknown and/or not possible to triage with the current info
postgREST
related to PostgREST
Bug report
Describe the bug
I am trying to route my table entry and update via server api and including access_token in the header. And access_token, I am getting it from auth.getSession(). But getting 401 error. In the app, I can see the session with access_token.
What is the right approach to do this?
const response = await fetch( "https://mydomain.com/api/seller/ext_order", { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: Bearer ${access_token}, }, body: JSON.stringify(data), }, );
I have done my login using library. does that make any difference?
const {data, error} = await supabase.auth.signInWithOtp({ phone: phone_number, });
P.S
In the nextjs app route, I am able to see the header with Bearer token.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Use access_token from auth.getSession() and send the request to server API.
Expected behavior
access_token should allow the user to perform authed activities in the backend.
System information
The text was updated successfully, but these errors were encountered: