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

example redirect to ${ROOT_DOMAIN}/login to app.${ROOT_DOMAIN}/login #426

Open
arafays opened this issue Aug 7, 2024 · 1 comment
Open

Comments

@arafays
Copy link

arafays commented Aug 7, 2024

I have been trying to redirect the login page of the app for a while this is how I got it done.

platforms/middleware.ts

Lines 62 to 69 in 7e33556

if (
hostname === "localhost:3000" ||
hostname === process.env.NEXT_PUBLIC_ROOT_DOMAIN
) {
return NextResponse.rewrite(
new URL(`/home${path === "/" ? "" : path}`, req.url),
);
}

if (
  hostname === "localhost:3000" ||
  hostname === process.env.NEXT_PUBLIC_ROOT_DOMAIN
) {
  const https = hostname === 'localhost:3000' ? 'http' : 'https';
  if (path === "/login") {
    return NextResponse.redirect(new URL(`${https}://app.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/login`, req.url));
  }  else if (path === "/settings") {
    return NextResponse.redirect(new URL(`${https}://app.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/settings`, req.url));
  }

  return NextResponse.rewrite(
    new URL(`/home${path === "/" ? "" : path}`, req.url),
  );
}

am I doing this correctly or is there a better way?

@CrutchTheClutch
Copy link

I wrote up a response recently in another issue with the same issue: #329 (comment). This was the best way I found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants