Hey, having a issue with token refreshing on react...
# support-questions-legacy
u
Hey, having a issue with token refreshing on react native but not web. The nextjs app refreshes the token correctly when the server sends a 401, but the expo app does not. I checked over the setting started guide and all looks correct. The server is sending the refe Supertokens passwordless application accessed via a expo app running on Expo sdk 46.0.16 with supertokens-react-native 3.2.0 ("also tried with 4.0.0") Node graphql server running supertokens-node 12.1.6 Nextjs@12 app runningsupertokens-auth-react 0.27.2. The appInfo all looks to be correct, its sharing the same config via a monorepo. Both next and expo apps are using graphql-request ^5.0.0 to for the requests Server response to expo app
Copy code
store-api:dev:   meta: {
store-api:dev:     req: {
store-api:dev:       url: '/graphql',
store-api:dev:       headers: {
store-api:dev:         host: 'localhost:9002',
store-api:dev:         accept: '*/*',
store-api:dev:         'content-type': 'application/json',
store-api:dev:         connection: 'keep-alive',
store-api:dev:         cookie: 'sIdRefreshToken=xxxxxx',
store-api:dev:         'accept-language': 'en-US,en;q=0.9',
store-api:dev:         'content-length': '1179',
store-api:dev:         'accept-encoding': 'gzip, deflate',
store-api:dev:         'user-agent': 'Expo/2.25.3.101 CFNetwork/1402.0.8 Darwin/22.2.0'
store-api:dev:       },
store-api:dev:       method: 'POST',
store-api:dev:       httpVersion: '1.1',
store-api:dev:       originalUrl: '/graphql',
store-api:dev:       query: {}
store-api:dev:     },
store-api:dev:     res: { statusCode: 401 },
store-api:dev:     responseTime: 1
store-api:dev:   },
n
Hi @__jono Are you using axios in your react native app?
u
Hey, nope using graphql-request https://www.npmjs.com/package/graphql-request which uses
cross-fetch
. Would using axios make a difference?
n
Could you try using vanilla fetch to see if that works? Just to rule it out
u
Hey so yeah, it works with pure fetch but using any fetch polyfill causes it to fail. I tried with - whatwg-fetch - isomorphic-fetch - unfetch All producing the same result. My current workaround for expo is to use the response middleware from graphql-requests to check for
401
status code and manually call the
attemptRefresh
method. Would it be possible in future to support refreshing in polyfils or other fetch based libraries?
n
Hmm, could you open an issue about this in supertokens-react-native? We can add this to the roadmap and have it rolled out in the future
7 Views