Skip to content

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

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

Closed
1 of 3 tasks
zachleat opened this issue May 10, 2023 · 0 comments · Fixed by #2099
Closed
1 of 3 tasks

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

zachleat opened this issue May 10, 2023 · 0 comments · Fixed by #2099
Assignees
Labels
Ecosystem: Frameworks type: bug code to address defects in shipped code

Comments

@zachleat
Copy link

zachleat commented May 10, 2023

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/[email protected]"
		}
	],
	"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.
@zachleat zachleat added the type: bug code to address defects in shipped code label May 10, 2023
@zachleat zachleat self-assigned this May 10, 2023
@kodiakhq kodiakhq bot closed this as completed in #2099 Jun 12, 2023
kodiakhq bot pushed a commit that referenced this issue Jun 12, 2023
* fix: strip domain from ipx edge functions path (#2098)

* chore: add unit tests for sanitizer for #2098

---------

Co-authored-by: Lennart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ecosystem: Frameworks type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants