Skip to content

[Bug]: Full domain URLs in images.path config bypass Edge functions #2098

Closed
@zachleat

Description

@zachleat

Summary

With a next.config.js file like this:

module.exports = {
  images: {
    path: `https://example.com/_next/image`,
  },
}

The Netlify edge function manifest.json outputs:

{
	"functions": [
		{
			"function": "ipx",
			"name": "next/image handler",
			"path": "https://example.com/_next/image",
			"generator": "@netlify/next-runtime@4.36.1"
		}
	],
	"layers": [
		{
			"name": "https://ipx-edge-function-layer.netlify.app/mod.ts",
			"flag": "ipx-edge-function-layer-url"
		}
	],
	"version": 1
}

The problem here is that domains in path are not supported for Edge functions, similar to what you might expect in domain-level redirects.

Steps to reproduce

  1. Navigate to https://melodious-rugelach-38894a.netlify.app/
  2. Each of the first 4 links should render as Hello world Edge text
  3. Changing config.path in netlify/edge-functions/ipx.js to /_next/image fixes the issue.

A link to a reproduction repository

https://github.com/zachleat/edge-redirects-test

Next Runtime version

4.36.1

Is your issue related to the app directory (beta)?

  • Yes, I am using the app directory

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

None

Your netlify.toml file

`netlify.toml`
# Paste content of your `netlify.toml` file here

Your public/_redirects file

`_redirects`
# Paste content of your `_redirects` file here

Your next.config.js file

`next.config.js`
# Paste content of your `next.config.js` file here. Check there is no private info in there.

Builds logs (or link to your logs)

Build logs
# Paste logs here

Function logs

Function logs
# Paste logs here

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions