Skip to content

Support localized redirect url in storefrontRedirect #2564

@juanpprieto

Description

Hello,

I had few cases were I couldn't use storefrontRedirect so I had to do my own implementation (by copy-pasting storefrontRedirect code and modify it).

The main thing is that it doesn't handle route params, e.g locale.

For example, there is a redirect configured in Shopify like following:
From: /myUrlFrom, To: /myUrlTo

The storefront redirect will not handle theses:

/fr/myUrlFrom/ -> doesn't match any redirect url

So we should have a parameter or something to deal with locale.

In my own implementation I added 2 paramaters:

/* locale (e.g: fr-fr) to prefix redirect url, if the redirect url is absolute then we don't prefix it /
localePrefix?: string;
/
Full string url. e.g: https://example.com/search?query=param, it will be used to match the redirect url */
matchingUrl: string;
Since we are not tied anymore to the request parameter we can pass everything we want. Also if we want to prefix the redirect url we can.

Context #2562 (comment)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions