Skip to content

Rewrites to _next/static files not working #2628

Open
@pieh

Description

@pieh

Asset prefix tests with fixture like this: https://github.com/vercel/next.js/blob/4837a67fb9bc7199e48cd8bd2cc42659b17dfacc/test/e2e/app-dir/asset-prefix/next.config.js

is unable to handle rewrite that would match static files (such as /custom-asset-prefix/_next/static/chunks/app/page-0c41902c3edd4280.js which should just serve /_next/static/chunks/app/page-0c41902c3edd4280.js)

This results in failure for those tests:

Some investigation notes:

It seems like next-server is building maps of various such files on server initialization ( https://github.com/vercel/next.js/blob/4837a67fb9bc7199e48cd8bd2cc42659b17dfacc/packages/next/src/server/lib/router-utils/filesystem.ts#L98-L680 ) and later used in when handling requests ( https://github.com/vercel/next.js/blob/4837a67fb9bc7199e48cd8bd2cc42659b17dfacc/packages/next/src/server/lib/router-server.ts#L417-L525 ), but we are not bundling those files into server handler and therefore it falls back to 404 case that we see.

This is possible same root issue as #2465 (?)

Data

The following is parsed automatically by the Next.js repo e2e test report generator.

test: test/e2e/app-dir/asset-prefix/asset-prefix.test.ts, test/e2e/app-dir/asset-prefix-with-basepath/asset-prefix-with-basepath.test.ts, test/e2e/app-dir/asset-prefix-absolute/asset-prefix-absolute.test.ts
reason: Rewrites to _next/static files not working

Metadata

Metadata

Assignees

No one assigned

    Labels

    Next.js e2e test failureErrors identified through the Next.js repo e2e tests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions