-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Nextjs app with a basePath assets don't load #6655
Copy link
Copy link
Open
Description
Bug:
NextJs app with basePath results in assets 403'ing
How to reproduce
run npx sst deploy on this repo
https://github.com/willwashburn/sst-basepath-assets-issues
load the index page. assets get 403'd
Expected
With basePath: "/example-base-path", these should resolve:
GET /example-base-path/_next/static/...->200GET /example-base-path/favicon.svg->200
Actual
The HTML references base-path-prefixed assets, but only root asset paths work:
GET /example-base-path/_next/static/...->403GET /_next/static/...->200GET /example-base-path/favicon.svg->403GET /favicon.svg->200
Root Cause
This looks like an SST CloudFront router bug.
OpenNext v3.9.16 emits base-path-aware S3 copy metadata:
But SST’s router strips the base path only for matching, then reuses the original request URI when rewriting to S3
So a request like:
/example-base-path/_next/static/chunks/app.css
matches using:
/_next/static/chunks/app.css
but gets rewritten to S3 as:
/_assets/example-base-path/_next/static/chunks/app.css
instead of:
/_assets/_next/static/chunks/app.css
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.