Next.js Discord

Discord Forum

Static Asset Loading Issue in Next.js Application From CDN

Unanswered
Philippine Crocodile posted this in #help-forum
Open in Discord
Avatar
Philippine CrocodileOP
Overview:
We are encountering an issue where static assets (e.g., JavaScript chunks) are not being correctly loaded from the designated CDN despite setting the assetPrefix in the next.config.js. This behavior differs between local development and the deployed environment (AWS ECS with Docker). Specifically:

1. Local Development (yarn dev):

The application attempts to fetch static chunks from the CDN defined by the assetPrefix.



2. Deployed Environment (AWS ECS):

Only images are being fetched from the CDN, while JavaScript chunks and other static assets are being loaded from the default paths (e.g., /next/static/...) instead of the CDN.


Steps Taken:

1. Verified that assetPrefix is correctly set in next.config

2. Confirmed that the static files (JavaScript chunks, CSS, and images) are uploaded to the S3 bucket backing the CDN.


3. Observed that the browser's network tab shows assets being fetched from incorrect paths in the deployed environment.


Can anyone help me with this please?

0 Replies