File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed
test/e2e/app-dir/asset-prefix-absolute Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -1707,7 +1707,8 @@ export default abstract class Server<
1707
1707
) : Promise < void >
1708
1708
1709
1709
public setAssetPrefix ( prefix ?: string ) : void {
1710
- this . renderOpts . assetPrefix = prefix ? prefix . replace ( / \/ $ / , '' ) : ''
1710
+ this . nextConfig . assetPrefix = prefix ? prefix . replace ( / \/ $ / , '' ) : ''
1711
+ this . renderOpts . assetPrefix = this . nextConfig . assetPrefix
1711
1712
}
1712
1713
1713
1714
protected prepared : boolean = false
Original file line number Diff line number Diff line change
1
+ import { nextTestSetup } from 'e2e-utils'
2
+
3
+ describe ( 'app-dir absolute assetPrefix' , ( ) => {
4
+ const { next } = nextTestSetup ( {
5
+ files : __dirname ,
6
+ nextConfig : {
7
+ assetPrefix : 'https://example.vercel.sh/' ,
8
+ } ,
9
+ } )
10
+
11
+ it ( 'bundles should return 200 on served assetPrefix' , async ( ) => {
12
+ const $ = await next . render$ ( '/' )
13
+
14
+ let bundles = [ ]
15
+ for ( const script of $ ( 'script' ) . toArray ( ) ) {
16
+ const { src } = script . attribs
17
+ if ( src ?. includes ( 'https://example.vercel.sh/_next/static' ) ) {
18
+ bundles . push ( src )
19
+ }
20
+ }
21
+
22
+ expect ( bundles . length ) . toBeGreaterThan ( 0 )
23
+
24
+ for ( const src of bundles ) {
25
+ // Remove hostname to check if pathname is still used for serving the bundles
26
+ const bundlePathWithoutHost = decodeURI ( new URL ( src ) . pathname )
27
+ const { status } = await next . fetch ( bundlePathWithoutHost )
28
+
29
+ expect ( status ) . toBe ( 200 )
30
+ }
31
+ } )
32
+ } )
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ import { nextTestSetup } from 'e2e-utils'
3
3
describe ( 'app-dir absolute assetPrefix' , ( ) => {
4
4
const { next } = nextTestSetup ( {
5
5
files : __dirname ,
6
+ nextConfig : {
7
+ assetPrefix : 'https://example.vercel.sh/custom-asset-prefix' ,
8
+ } ,
6
9
} )
7
10
8
11
it ( 'bundles should return 200 on served assetPrefix' , async ( ) => {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments