Closed jtparrett closed 4 months ago
Hello,
I have the same issue, and it is not happening inside the Remix Loader but only in the action.
My version of node is the same.
I also added the Vercel recommendation using @vercel/remix instead of @remix-run/node
and vite config import { vercelPreset } from "@vercel/remix/vite";
But nothing helped
@jtparrett I have found a way around the issue in case you are interested.
I thought it was weird that in the loader it works but not in the action, So I dived inside Clerk code and realized they kind of piggy bag on our request.
So I tried to recreate a request that should work basically like in Loaders a get request with headers as this is where the Auth information is saved.
const generateNewRequestForClerk = (request: Request) => {
const originalRequest = request.clone();
const newRequestInit = {
method: "GET", // Change the method to GET
headers: new Headers(originalRequest.headers), // Copy headers from the original request
};
// Remove content-type header as it's not needed for GET and may cause issues
newRequestInit.headers.delete("Content-Type");
// Instantiate the new request without the body attribute
return new Request(originalRequest.url, newRequestInit);
};
const auth = await getAuth({
...args,
request: generateNewRequestForClerk(args.request),
});
Try it out and please tell me if it is working on your side too? 🙏
@octoper will look into this!
@octoper will look into this!
I can be available for any live coding meeting if needed
briardg
Thanks for this! Yes, that fix also worked in my case 👍 using it as a workaround for now.
@briardg thank you for the workaround, worked well on my end too
This was fixed with https://github.com/clerk/javascript/pull/3495 👍
Hello. I'm using clerk/remix on Cloudflare Pages, and when using getAuth
within an ActionFunction, it seems to generate a new error from the code that was fixed in the PR #3495 :thinking: The workaround provided seems to prevent the error from occurring.
TypeError: Cannot set property duplex of #<_Request> which has only a getter
at patchRequest (.../node_modules/@clerk/remix/dist/ssr/utils.js:115:26)
Hello. I'm using clerk/remix on Cloudflare Pages, and when using
getAuth
within an ActionFunction, it seems to generate a new error from the code that was fixed in the PR #3495 :thinking: The workaround provided seems to prevent the error from occurring.TypeError: Cannot set property duplex of #<_Request> which has only a getter at patchRequest (.../node_modules/@clerk/remix/dist/ssr/utils.js:115:26)
I just started a new project two days ago and I get the same error running on regular Node.js.
This was fixed with #3495 👍
But this unfortunately introduced a regression. Discussion on Discord here https://discord.com/channels/856971667393609759/1253975184818573313
@arminnaimi I have reported this bug. Hopefully they will fix it soon. In the meantime you can just downgrade to the previous version of @clerk/remix.
Thanks you for reporting that I will take a look at it today!
Hey!
We have released a fix for the regression that was introduced in #3495, you can upgrade to the latest version of the Remix SDK and it will be resolved!
Preliminary Checks
[X] I have reviewed the documentation: https://clerk.com/docs
[X] I have searched for existing issues: https://github.com/clerk/javascript/issues
[X] I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
[X] This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction
https://github.com/jtparrett/rcdriftuk-website
Publishable key
pk_live_Y2xlcmsucmNkcmlmdC51ayQ
Description
This issue only happens in production on vercel, this issue DOES NOT HAPPEN LOCALLY.
I have included the production repo just because the issue only happens in production on vercel.
The problem is with any remix action that uses getAuth() will give the error below regarding a duplex option on the body.
The error happens when using node 20 or node 18. I've also tried updating every possible package.
Please see file: app/routes/events.$id.tsx -> action
Steps to reproduce:
Expected behavior: The getAuth method should return the user
Actual behavior: The getAuth method has the following error
Environment