Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ function addRewriteFramesLoader(
target: 'server' | 'client',
userNextConfig: NextConfigObject,
): void {
// Nextjs will use `basePath` in place of `assetPrefix` if it's defined but `assetPrefix` is not
const assetPrefix = userNextConfig.assetPrefix || userNextConfig.basePath || '';
const replacements = {
server: [
[
Expand All @@ -693,9 +695,7 @@ function addRewriteFramesLoader(
'__ASSET_PREFIX_PATH__',
// Get the path part of `assetPrefix`, minus any trailing slash. (We use a placeholder for the origin if
// `assetPreix` doesn't include one. Since we only care about the path, it doesn't matter what it is.)
userNextConfig.assetPrefix
? new URL(userNextConfig.assetPrefix, 'http://dogs.are.great').pathname.replace(/\/$/, '')
: '',
assetPrefix ? new URL(assetPrefix, 'http://dogs.are.great').pathname.replace(/\/$/, '') : '',
],
],
};
Expand Down