Vercel add trailing slash for rewrite destination causing failures

I’ve created a repository for this purpose to demonstrate what the problem is: GitHub - cxplay/vercel-rewrite-issue: vercel-rewrite-issue

The vercel.json expectation should rewrite /whichpath.vercel.app/web/path to https://whichpath.vercel.app/web/path so that the body of the HTTP response is /web/path.

{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "rewrites": [
    {
      "source": "/(whichpath.vercel.app/web/path)",
      "destination": "https://$1"
    }
  ]
}

But the actual response is:

❯ curl https://vercel-rewrite-issue-red.vercel.app/whichpath.vercel.app/web/path
/web/path/

The problem is in the trailing slash, which causes some Web services that don’t adapt to the trailing slash to fail to find the target.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.