Skip to content

Commit b04ff40

Browse files
committed
fix: strip domain from ipx edge functions path (#2098)
1 parent 2eba019 commit b04ff40

File tree

1 file changed

+7
-1
lines changed
  • packages/runtime/src/helpers

1 file changed

+7
-1
lines changed

packages/runtime/src/helpers/edge.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ export const loadPrerenderManifest = (netlifyConfig: NetlifyConfig): Promise<Pre
9393
*/
9494
const sanitizeName = (name: string) => `next_${name.replace(/\W/g, '_')}`
9595

96+
/**
97+
* Convert the images path to strip the origin (until domain-level Edge functions are supported)
98+
*/
99+
const sanitizeEdgePath = (imagesPath: string) => new URL(imagesPath, process.env.URL || 'http://n').pathname
100+
96101
// Slightly different spacing in different versions!
97102
const IMPORT_UNSUPPORTED = [
98103
`Object.defineProperty(globalThis,"__import_unsupported"`,
@@ -485,10 +490,11 @@ export const writeEdgeFunctions = async ({
485490
join('.netlify', 'functions-internal', IMAGE_FUNCTION_NAME, 'imageconfig.json'),
486491
join(edgeFunctionDir, 'imageconfig.json'),
487492
)
493+
488494
manifest.functions.push({
489495
function: 'ipx',
490496
name: 'next/image handler',
491-
path: nextConfig.images.path || '/_next/image',
497+
path: nextConfig.images.path ? sanitizeEdgePath(nextConfig.images.path) : '/_next/image',
492498
generator,
493499
})
494500

0 commit comments

Comments
 (0)