Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Router push takes subdomain name? #17

Closed
28development opened this issue Aug 8, 2021 · 2 comments
Closed

Router push takes subdomain name? #17

28development opened this issue Aug 8, 2021 · 2 comments

Comments

@28development
Copy link

28development commented Aug 8, 2021

I encountered the following case using router push redirects to the given route but adds the subdomain name, is this done on purpose? I am not sure if it's a krabs issue.

In my case I have following subdomain locally:

http://local.mickey.com:3000/login

on submit I do a simple react router push like this:

  const login = (e) => {
    e.preventDefault();
    router.push(`dashboard`);
  };

This redirects to following URL

http://local.mickey.com:3000/mickey/dashboard

which strangely shows the correct content / page. After I refresh this page it returns a 404.
The actual URL should be http://local.mickey.com:3000/dashboard (without the subdomain's name mickey)

If I add a slash to my router push like this:

  const login = (e) => {
    e.preventDefault();
    router.push(`/dashboard`);
  };

it redirects properly to this URL http://local.mickey.com:3000/dashboard

But adding a slash is "wrong" since adding it does a complete refresh of the next page.

If this is the indented behavior, is there a way to remove the subdomain's name here ....:3000/SUBDOMAIN/dashboard

May this happen because I have the login page inside my subdomain inside the pages directory so it default adds its name?

pages
  mickey
    login
    dashboard

putting it one level above would destroy the tenant's login behavior I try to accomplish.

@micheleriva
Copy link
Owner

I gotta be honest; I always push routes with a /, in your case: /dashboard.

As for now, you can use URL rewrites to mask the redirect or just use the / before the route name.`

@28development
Copy link
Author

I am closing this, I think this is due the tenants being in the pages directory

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

No branches or pull requests

2 participants