(SUPABASE NEXTJS 13) Error AuthApiError: invalid flow state, no valid flow state found
Unanswered
lucas posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/605852001942765592/0724eb666d65852eea264ba859304b54.webp?size=256)
lucasOP
Hi good afternoon, I am having problems while using nextjs 13 and supabase for authentication more specifically the provider I am using is the one from github, I have all the settings that are required in the documentation and I don't know what can be the problem.
- error AuthApiError: invalid flow state, no valid flow state found
at handleError (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:36:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _handleRequest (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:84:9)
at async _request (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:63:18)
at async SupabaseAuthClient._exchangeCodeForSession (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/GoTrueClient.js:377:33)
at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/GoTrueClient.js:784:28) {
__isAuthError: true,
status: 403
}
- error AuthApiError: invalid flow state, no valid flow state found
at handleError (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:36:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _handleRequest (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:84:9)
at async _request (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:63:18)
at async SupabaseAuthClient._exchangeCodeForSession (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/GoTrueClient.js:377:33)
at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@supabase+gotrue-js@2.48.1/node_modules/@supabase/gotrue-js/dist/main/GoTrueClient.js:784:28) {
__isAuthError: true,
status: 403
}
![Image](https://cdn.discordapp.com/attachments/1149170675181961216/1149170675400052837/image.png?ex=65d6b297&is=65c43d97&hm=80f940576cd8b148c4c2ed774151338a4972da580109aa1bd3b0caa3bfd497f5&)
5 Replies
![Avatar](https://cdn.discordapp.com/avatars/605852001942765592/0724eb666d65852eea264ba859304b54.webp?size=256)
lucasOP
My component to run the authentication
![Image](https://cdn.discordapp.com/attachments/1149170675181961216/1149171166771159110/image.png)
And my route
![Image](https://cdn.discordapp.com/attachments/1149170675181961216/1149171307301306479/image.png)
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Spectacled bear
Hello @lucas . Have you found a reason? I also have this issue, but only the first time I start the project. After that it works
![Avatar](https://cdn.discordapp.com/avatars/605852001942765592/0724eb666d65852eea264ba859304b54.webp?size=256)
lucasOP
Hi @Spectacled bear the only solution I found was to capture the session from the cookies (server side) and redirect to the login in case I don't have basically what the middleware does, I did it in the design therefore it is inherited
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Spectacled bear
Thank you!