Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was 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

@will093

Description

@will093

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/...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions