Skip to content
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

Docs: Is the port property necessary for remote patterns #44660

Closed
IDrumsey opened this issue Jan 6, 2023 · 4 comments · Fixed by #60387
Closed

Docs: Is the port property necessary for remote patterns #44660

IDrumsey opened this issue Jan 6, 2023 · 4 comments · Fixed by #60387
Labels
Documentation Related to Next.js' official documentation. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@IDrumsey
Copy link
Contributor

IDrumsey commented Jan 6, 2023

What is the improvement or update you wish to see?

The docs on configuring remote patterns shows using the port number property as an empty string,

{
    protocol: '...',
    port: '',
    hostname: '...',
    pathname: '...'
}

but when I run next run dev I get a warning

warn  - Invalid next.config.js options detected: 
  - The value at .images.remotePatterns[...].port must be 1 character or more but it was 0 characters.

Should I just omit the port property. If so, maybe adding some documentation for that would be good.

Is there any context that might help us understand?

no

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/api-reference/next/image#remote-patterns

NEXT-2016

@IDrumsey IDrumsey added the Documentation Related to Next.js' official documentation. label Jan 6, 2023
@spanarin
Copy link

I face the same issue. Maybe

port: '*',

will be a valid config for this case and the doc needs to be updated to reflect that?

@styfle
Copy link
Member

styfle commented Jan 8, 2024

The port is not required, but it is strongly recommended.

In fact, every prop in remotePatterns is strongly recommended to protect your application from malicious users.

Note that port: '' is not the same as port: undefined because undefined is effectively a wildcard. When you use port: '', that means you allow images from https://example.com/img.png, but not https://example.com:22/img.png

I'll make sure the json schema is correct and the docs explain this better, thanks!

@styfle styfle added the linear: next Confirmed issue that is tracked by the Next.js team. label Jan 8, 2024
@styfle
Copy link
Member

styfle commented Jan 8, 2024

I'm not seeing that warning anymore with the latest Next.js (14.0.4) so that issue is likely fixed.

I'll update the docs in PR #60387, thanks!

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Related to Next.js' official documentation. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants