-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Vercel rewrites not working #6446
Comments
This is also true for rewrites in Vercel middleware. |
Currently using rewrite with static files works but server rendered files with either edge or serverless function don't get rewritten. See: withastro#6446
Same issue here, but in my case, it fails only with the root. For sub-directories it works well |
@cruzlutor are those sub directories static? Vercel itself handles rewrites for static content. It’s SSR content where Astro needs to handle the rewrite headers. |
Currently using rewrite with static files works but server rendered files with either edge or serverless function don't get rewritten. See: #6446
Hey y'all, circling back to this! We've landed middleware support in Astro and edge middleware support for our Vercel adapter, so I'd recommend leaning on those features to accomplish this for now. After discussing this with the team, we agree that respecting |
From what I can observe, rewrites for non-existent pages do work, i.e. existing Astro pages takes precedence when they conflict with Vercel config. |
I was reporting a different issue and saw just how many open issues relate to Vercel and figured I'd share the only way I figured out to ship a recent (April/May) Astro project for my client was to ditch Vercel. I had so many issues with Vercel, middleware, etc -- Really any nontrivial Vercel feature with an Astro deployment. I had an i18n scenario with translated URL's + RTL where the whole nine yards of rewrites, edge functions, etc played a role. I found myself in the same boat as y'all experimenting with different things, trying to understand what was working and what wasn't... nothing substantial is configurable and the "under the hood" of Vercel is not well documented... nor apparently well-understood by their support team either... What worked? I switched to S3 + CloudFront deployment (with Edge Lambda for any rewrites etc) and used GitHub Actions to implement the preview deployments and haven't looked back. You can even do it in about as much time as it will take their support to turnaround ;) AWS docs are often meh but in this case they provide extensive use-case based examples for both Edge Lambdas and Cloud Functions (take note of the difference for your use-case!) for CloudFront. GitHub is full of in-production examples as well. Really I think Vercel knows their own dogfood well (NextJS) and after that good luck. I would still recommend Vercel for certain teams and use-cases however not for anything that's not NextJS. At the time (and maybe even still) it felt like they hadn't even thought of the possibility that someone might have a monorepo aka a project where paths don't line up exactly to their presumably hardcoded scenarios for file paths to middleware and the like for any project that isn't NextJS. By making Vercel so "easy" and stripping all possibility of configuration I found it was impossible to get it to align with Astro in a completely typical Nx monorepo structure. |
Is this because we generate our own vercel.json and don't merge it with yours? |
@Ehesp any updates? Could you please follow up? |
Going to go ahead and close since there hasn't been any follow-up here. Please create a new issue if you are able to still reproduce this, thank you. |
Currently using rewrite with static files works but server rendered files with either edge or serverless function don't get rewritten. See: withastro/astro#6446
What version of
astro
are you using?2.0.18
Are you using an SSR adapter? If so, which one?
Vercel
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
Rewrites inside of a
vercel.json
file are not applied (note, redirects do seem to work).Also see https://discord.com/channels/830184174198718474/1077242845406167112/1077242845406167112
To reproduce, add this to your
vercel.json
and deploy:See repro link below. The index page should rewrite to page2:
https://astro-vercel-rewrites.vercel.app/
Link to Minimal Reproducible Example
https://github.com/Ehesp/astro-vercel-rewrites
Participation
The text was updated successfully, but these errors were encountered: