remix icon indicating copy to clipboard operation
remix copied to clipboard

Broken Routing: Remix + React Router integration branch

Open cephalization opened this issue 2 years ago • 1 comments

What version of Remix are you using?

0.0.0-experimental-5b4bceda6

Steps to Reproduce

Within a Remix loader, call the redirect function with a fully qualified URL like https://google.com

Example loader:

export const loader = async ({ request }: LoaderArgs) => {
  const session = await requestSession(request);
  const auth = getAuthFromSession(session);

  // don't try to login again if already logged in
  if (auth) {
    return redirect("/");
  }

  // this hits a 3rd party api and returns a 304 redirect response with destination
  const res = await getLogin();

  if (res.redirected) {
    return redirect(res.url);
  }

  return redirect("/");
};

Expected Behavior

Calling redirect with a fully qualified url takes my user to that URL.

Actual Behavior

Calling redirect with a fully qualified url takes my user to my site url with the redirect url appended to the end

Like http://localhost:3000/https://google.com

cephalization avatar Nov 11 '22 00:11 cephalization

I found the code causing this issue and wrote an integration test to verify.

I will play around with a few solutions. I assume this issue happens because in react router we mostly assume you are routing within an SPA but in remix that’s not necessarily the case.

cephalization avatar Nov 11 '22 14:11 cephalization

This should be resolved in 1.8.0-pre.2 - @cephalization do you want to confirm your use-case?

brophdawg11 avatar Nov 30 '22 20:11 brophdawg11

Works great @brophdawg11 , thanks!

cephalization avatar Dec 01 '22 01:12 cephalization

Released in 1.8.0

brophdawg11 avatar Dec 01 '22 14:12 brophdawg11