Skip to content

useFetcher CORS error on 302 redirect response when using authentication flow with OAUTH2 proxy server #13357

@TheBadam

Description

@TheBadam

I'm using React Router as a...

framework

Reproduction

Clone repo: https://github.com/TheBadam/ReactRouterBugs
Run docker compose up and with DEV tools open in i.e.: Edge click the "Click!" text. This should fire fetch through useFetcher and should fail. nginx proxy redirects any /__manifest request to https://login.microsoft.com which will in process fail with CORS error.
This is a simplified example of using oatuh2-proxy from: https://github.com/oauth2-proxy/oauth2-proxy when cookie expires/is removed. Currently there is no control of how useFetcher reacts for redirects and requires some nasty hacks - unless there is other solution?
We use useFetcher to load data in app.

System Info

System:
    OS: Linux 6.8 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (2) x64 Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
    Memory: 5.87 GB / 7.75 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 20.8.1 - ~/nvm/current/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.1.0 - ~/nvm/current/bin/npm
    pnpm: 8.9.2 - ~/nvm/current/bin/pnpm

Used Package Manager

npm

Expected Behavior

On authentication 302 redirect (certain redirect), navigate instead of fetch or at least expose fetch options to handle it on client side, i.e.: {redirect: "manual"}.

Actual Behavior

CORS fetch error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions