Shopify / hydrogen-v1

React-based framework for building dynamic, Shopify-powered custom storefronts.
https://shopify.github.io/hydrogen-v1/
MIT License
3.75k stars 326 forks source link

Make Shopify Admin redirects easy #1326

Open benjaminsehl opened 2 years ago

benjaminsehl commented 2 years ago

There should be an out of the box implementation for implementing the redirects available at /admin/redirects in Hydrogen.

The router would then ideally work something like this (naming should be workshopped) …

<Router>
   <ShopifyAdminRedirects /> 
   <FileRoutes />
   <Route path="*" page={<NotFound />} />
</Router>

We would leverage the redirect API here: https://shopify.dev/api/storefront/2022-07/objects/UrlRedirect

Caveats would include that this would apply for both Online Store and Hydrogen — which may not be desirable. This needs to be looked at from the admin perspective with the broader team, in addition to the Menus UI.

In an optimal solution, it would be worth considering having this also be implemented at the Oxygen level for lowest latency — but Hydrogen would still need to implement so it could be available in all hosting solutions.

benjaminsehl commented 2 years ago

@davecyen — I thought we'd looked at this already, but maybe we moved on at the time since the redirect API hadn't yet been exposed?

davecyen commented 2 years ago

Yeah would be nice. There were some questions around performance impact and potentially having these routes fetched within a boot hook. @blittle do you recall?

ahbyass commented 1 year ago

Any update on this

blittle commented 1 year ago

@AlexanderBMAS the storefront API added the ability to query redirects by path. The recommended solution at the moment is just to manually make that request on a 404 page. If the redirect exists, forward the user, else serve a 404 page.