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

The page does not hydrate on the client after a URL rewrite #1799

Open
will093 opened this issue Sep 24, 2021 · 0 comments
Open

The page does not hydrate on the client after a URL rewrite #1799

will093 opened this issue Sep 24, 2021 · 0 comments

Comments

@will093
Copy link

will093 commented Sep 24, 2021

Describe the bug

URL rewrites don't work with Sapper, the page does not hydrate an the client. The issue occurs when using any kind of redirect middleware, eg.

const rewriteUrl = () => {
  return (req, res, next) => {
    if (req.url === "/about2") {
      req.url = req.originalUrl = `/about`;
      next("route");
    } else {
      next();
    }
  };
};

To Reproduce

Example code here:

https://github.com/will093/sapper-url-rewrite-issue

On the route /about2, I am expecting the after the rewrite to load the same content as the /about page and hydrate it properly, instead it does a server render but then the app never hydrates on the client.

Expected behavior

Page whose URL gets rewritten should hydrate properly.

Severity

Severe

The issue is preventing me from setting up locale/market based routing for my site.

Additional context

Some context to my problem in case there is another way to do this with Sapper. I have different language/market based routes, like:

my-site.com/de/...
my-site.com/se/...

And I want to use URL rewrites to set up something like this as a default:

my-site.com/... --> mysite.com/world/...

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

1 participant