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

next.config.js is not considered for node_modules that import next/image #31065

Closed
styfle opened this issue Nov 6, 2021 · 9 comments · Fixed by #33559
Closed

next.config.js is not considered for node_modules that import next/image #31065

styfle opened this issue Nov 6, 2021 · 9 comments · Fixed by #33559
Assignees
Labels
Image (next/image) Related to Next.js Image Optimization.

Comments

@styfle
Copy link
Member

styfle commented Nov 6, 2021

What version of Next.js are you using?

12.0.3

What version of Node.js are you using?

16.x

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

next start

Describe the Bug

Getting an error during next dev when a dependency imports next/image:

Error: Invalid src prop (https://i.imgur.com/CgezKMb.jpg) on next/image, hostname "i.imgur.com" is not configured under images in your next.config.js
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host

Expected Behavior

Should read the next.config.js properly, even for 3rd party packages inside node_modules that import next/image

To Reproduce

https://github.com/pacocoursey/next-image-bug

@styfle styfle added kind: bug Image (next/image) Related to Next.js Image Optimization. labels Nov 6, 2021
@styfle styfle self-assigned this Nov 6, 2021
@styfle styfle added this to the 12.0.4 milestone Nov 6, 2021
@timneutkens timneutkens removed this from the 12.0.5 milestone Nov 17, 2021
@styfle
Copy link
Member Author

styfle commented Jan 5, 2022

Some additional context: this is not just relevant for 3rd party packages published to npm, but also monorepos using workspaces or private packages shared between projects.

@johnnyomair
Copy link
Contributor

While investigating a similar issue (see #33228) I've found that the next.config.js is also not considered when using the next/image component in a 3rd party package in combination with the priority flag.

@trevorgillis
Copy link

I am having this exact issue. What's especially odd is that, when I run next dev, I get the error and my app doesn't load (as expected and stated in the issue). If I then, in my Next.js app, temporarily comment out the third-party code that's using next/image and reload, it loads without the error (as expected). But then, while the dev server is still running, if I uncomment the third-party code that's using next/image, it works.

It is also not an issue when I do a build and run in production mode; it only happens in development mode.

@trevorgillis
Copy link

@styfle have you found any temporary workarounds for the time being?

@styfle
Copy link
Member Author

styfle commented Jan 24, 2022

Theres a PR you could try out: #33559

@ambrauer
Copy link

ambrauer commented Feb 4, 2022

Hi @styfle - just curious, any anticipated release milestone for this fix?

@styfle
Copy link
Member Author

styfle commented Feb 4, 2022

We'll have it for 12.1.0.

The work is being done in PR #33559

@styfle
Copy link
Member Author

styfle commented Feb 9, 2022

This was released in 12.0.11-canary.10.

You can try it out today with npm i next@canary or yarn add next@canary, thanks!

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. 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 Mar 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Image (next/image) Related to Next.js Image Optimization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants