-
Notifications
You must be signed in to change notification settings - Fork 29k
Ensure setAssetPrefix updates config instance #82160
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1652,7 +1652,7 @@ export default abstract class Server< | |
): Promise<void> | ||
|
||
public setAssetPrefix(prefix?: string): void { | ||
this.renderOpts.assetPrefix = prefix ? prefix.replace(/\/$/, '') : '' | ||
this.nextConfig.assetPrefix = prefix ? prefix.replace(/\/$/, '') : '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The View DetailsAnalysisThe change on line 1655 modified
Both RecommendationThe public setAssetPrefix(prefix?: string): void {
const assetPrefix = prefix ? prefix.replace(/\/$/, '') : ''
this.nextConfig.assetPrefix = assetPrefix
this.renderOpts.assetPrefix = assetPrefix
} Alternatively, if the intention is to only store it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above referenced |
||
} | ||
|
||
protected prepared: boolean = false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('app-dir absolute assetPrefix', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
nextConfig: { | ||
assetPrefix: 'https://example.vercel.sh/', | ||
}, | ||
}) | ||
|
||
it('bundles should return 200 on served assetPrefix', async () => { | ||
const $ = await next.render$('/') | ||
|
||
let bundles = [] | ||
for (const script of $('script').toArray()) { | ||
const { src } = script.attribs | ||
if (src?.includes('https://example.vercel.sh/_next/static')) { | ||
bundles.push(src) | ||
} | ||
} | ||
|
||
expect(bundles.length).toBeGreaterThan(0) | ||
|
||
for (const src of bundles) { | ||
// Remove hostname to check if pathname is still used for serving the bundles | ||
const bundlePathWithoutHost = decodeURI(new URL(src).pathname) | ||
const { status } = await next.fetch(bundlePathWithoutHost) | ||
|
||
expect(status).toBe(200) | ||
} | ||
}) | ||
}) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still using renderOpts.assetPrefix here, do we still need to update the
renderOpts.assetPrefix
as well?next.js/packages/next/src/server/post-process.ts
Line 45 in d8d5e9e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#82160 (comment)