-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
turbo-stream error when redirecting through an action while preserving headers #12850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I didn't want to pollute the bug report so I'll post an explanation here: I'm trying to redirect with the headers for Supabase Auth, which needs the headers to be there for a code validation that it handles by itself. This is a concise version of my action:
Without the headers the redirect works fine but Supabase Auth fails with an AuthApiError ~~As a sidenote, I tried to write the minimal repro as a test in the bug-integration-test but, after figuring out the command is actually It's probably a skill issue of mine but I'll leave the link here as well in case someone wants to take a look: https://github.com/Kylar13/react-router/commit/85a20834be8e0cd04b534d7b8c1b43e96ef2ccdc~~ EDIT: Figured out the bug-report thing and submitted a PR |
My implementation of supabase looks like this
then in my actions/loaders etc I can use...
then I return these headers into the response. This also allows me to grab an admin sb client if needed. |
Have you tried using redirect() with the same headers used to initialize the client? That's what Supabase Auth needs to validate the auth request on the OAuth flow, and that's what's causing the issue right now. On email flow and in other places where the client is used, there's no issue. |
Got the bug-report thing to work, posted a pull request at #12876 |
OK sorry the process above is what I use for the token auth. For Google I have been using ReactOAuth2|Google and the One tap signin process. on the form I have
|
When i sign in using OAuth I use this function on my form...
This is what my callback looks like..
|
@JasonColeyNZ Yeah, you're doing OAuth from the client library, I wanted to set it up to all be server-side for this project, and ran into this bug Thanks for the help anyway! |
@Kylar13 We are having the same issue after migrating to react-router from remix6 I managed to boil it down to an action returning a response with a header set exactly as you. Did you manage to solve your issue? |
Hey!! No I did not, filed a bug report test showcasing the bug and even tried to dig into the code myself but got nowhere. Unfortunately, since I encountered this at the beginning of an experiment, I just ended up moving to using tanstack-start for it |
I have the same issue just fixed it so I remove all the headers from the request and took only needed ones which is cookies, and since I have an array of them I did it like this... or the copilot did like after 1000000000001 trials......... export const action: ActionFunction = async ({ request }) => {
const formData = await request.formData()
const response = await client.post('/login', { ...Object.fromEntries(formData) })
const headers = new Headers()
const cookies = response.headers['set-cookie']
if (Array.isArray(cookies)) {
cookies.forEach((cookie) => headers.append('set-cookie', cookie))
} else if (cookies) {
headers.append('set-cookie', cookies)
}
return redirect('/pictures', {
headers,
})
} |
I'm using React Router as a...
framework
Reproduction
git clone https://github.com/Kylar13/react-router-redirect-bug.git
pnpm i && pnpm dev
Go to https://localhost:3000
Press Redirect button
System Info
Used Package Manager
pnpm
Expected Behavior
The action redirects while preserving headers from the request.
Actual Behavior
The app crashes with the following error:
The text was updated successfully, but these errors were encountered: