Skip to content

Conversation

@hnsr
Copy link
Contributor

@hnsr hnsr commented Jan 19, 2026

Summary

When visiting a product URL without the configured product route prefix (e.g., /my-product instead of /p/my-product), the redirectOrNotFound function returns a 404 even though Magento's route resolver successfully identifies it as a product.

The Problem

The issue is in the redirect logic. When relative_url === from (which is the case when accessing /my-product), redirectUrl is undefined, and the code falls through to notFound even though:

  1. A valid route was found
  2. The route is identified as a product type

The Fix

Added a check after the existing redirect logic: if no explicit redirect URL exists but the route is identified as a product type, redirect to the product route anyway.

Test plan

  • Visit a product URL without the /p/ prefix (e.g., /my-product-slug)
  • Verify it redirects to /p/my-product-slug
  • Verify existing redirect behavior still works (URLs with suffixes, category redirects, etc.)

…ct route

When visiting a product URL without the configured product route prefix
(e.g., /my-product instead of /p/my-product), the redirectOrNotFound
function would return a 404 even though Magento's route resolver
successfully identified it as a product.

The issue occurs when relative_url equals the incoming URL - no redirect
was triggered because the code only redirected when relative_url !== from.
However, for products accessed without the /p/ prefix, we still need to
redirect to the product route even when the URL key matches.

This fix adds a check: if the route resolver finds a product but there's
no explicit redirect URL (relative_url === from), redirect to the product
route anyway.
@changeset-bot
Copy link

changeset-bot bot commented Jan 19, 2026

⚠️ No Changeset found

Latest commit: 9dca5a5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Jan 19, 2026

@hnsr is attempting to deploy a commit to the Reach Digital Team on Vercel.

A member of the Team first needs to authorize it.

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

Successfully merging this pull request may close these issues.

1 participant