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

Support localized redirect url in storefrontRedirect #2564

Open
juanpprieto opened this issue Sep 25, 2024 · 0 comments
Open

Support localized redirect url in storefrontRedirect #2564

juanpprieto opened this issue Sep 25, 2024 · 0 comments

Comments

@juanpprieto
Copy link
Contributor

juanpprieto commented Sep 25, 2024

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)

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

1 participant