Skip to content
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

[BUG] Normal request somehow getting "purpose = prefetch" header #567

Open
murbanowicz opened this issue Apr 11, 2025 · 3 comments
Open
Labels
bug Something isn't working triage

Comments

@murbanowicz
Copy link

murbanowicz commented Apr 11, 2025

Initially I thought it is about build,but found out it is not.

I am trying to move to Cloudflare with OpenNext.
I am using Kinde for auth (working great on Vercel).
Unfortunately, as they have a check for prefetch on login handler (other routes work ok) - https://github.com/kinde-oss/kinde-auth-nextjs/blob/main/src/handlers/login.ts#L12

After adding many debug logs in node_modules code, I managed to find out that in some way, when the request hit the handler, it has "purpose = prefetch" header set, which cause the handler to think it is prefetch and return null.

I was trying to figure out what is going on, but I cannot find any reason how this can happen.

Image

Above you can find a screenshot from my debugging attempt.

  console.log('isPreFetch - purpose', e.get("purpose") === "prefetch");
  console.log('isPreFetch - x-purpose', e.get("x-purpose") === "prefetch");
  console.log('isPreFetch - x-moz', e.get("x-moz") === "prefetch");

  return !!(e.get("purpose") === "prefetch" || e.get("x-purpose") === "prefetch" || e.get("x-moz") === "prefetch");
}
export {
  r as isPreFetch
};

dead simple logs put inside node_modules.

Any idea what can be going on here?

@murbanowicz murbanowicz added bug Something isn't working triage labels Apr 11, 2025
@murbanowicz murbanowicz changed the title [BUG] Building/bundling produces bundle with absolute local paths [BUG] Normal request somehow getting "purpose = prefetch" header Apr 11, 2025
@conico974
Copy link
Collaborator

This is caused by this https://github.com/opennextjs/opennextjs-aws/blob/73281c958d43d865fdded0d5d86dd82747365fee/packages/open-next/src/core/requestHandler.ts#L159-L164

We could move this to use a code patch now

@murbanowicz
Copy link
Author

Thanks Mate for jumping in.
What would you recommend to unblock myself? I do not know ON enough to contribute at this moment.

@conico974
Copy link
Collaborator

For now use something like pnpm patch to remove these lines https://github.com/kinde-oss/kinde-auth-nextjs/blob/d221023de87008ca1115ab2bcf9598ba79106df9/src/handlers/login.ts#L12-L14.
I'll make a patch for it early next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Development

No branches or pull requests

2 participants