Skip to content

redirect a POST rsc-x-component / fetch fails with CORS #289

@aheissenberger

Description

@aheissenberger

Describe the bug

I have a middleware which will redirect to my OAuth API to handle the OAuth Flow.
But the redirect from the middleware will not lead to a change of the document url. The ClientProvider will fetch and follow the redirect until the url is not part of the domain and fail with a CORS policy error.

Image

A solution might be to add a third parameter object to redirect() function to force the redirect to be done as a real location change in the browser by returning a redirect as a special rsc object which is interpreted by ClientProvider and issues a change of the location in the browser. The current problem comes from the fact that a real http redirect response object is issued and handled by the fetch request in ClientProvider.

Example:
redirect('/api/login',302,{force: 'native'})

The only working solution currently is not to replace the <Link> component with <a> tag which fixes some cases but not all.

Reproduction

No response

Steps to reproduce

No response

System Info

System:
    OS: macOS 15.7.1
    CPU: (12) arm64 Apple M4 Pro
    Memory: 1.96 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.2.1 - /opt/homebrew/bin/node
    npm: 11.6.2 - /opt/homebrew/bin/npm
    pnpm: 10.22.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 142.0.7444.176
    Safari: 26.0.1
  npmPackages:
    @lazarv/react-server: 0.0.0-experimental-600622d-20251109-6c5a6bee => 0.0.0-experimental-600622d-20251109-6c5a6bee

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions