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

Property overrideSrc of image component (next/image) does not override srcset property #65432

Open
sensedrive opened this issue May 7, 2024 · 2 comments
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.

Comments

@sensedrive
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/quirky-feistel-76hgmy?file=%2Fpages%2Findex.tsx%3A9%2C19

To Reproduce

Set the property overrideSrc as described in the docs https://nextjs.org/docs/app/api-reference/components/image#overridesrc

Both in dev and build the srcset property of the image won't be overridden.

Current vs. Expected behavior

Current:

The accessToken is being exposed in srcset!

Expected:

To be srcset property rewritten to bg.jpg

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 18.20.2
  npm: 10.5.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: 14.2.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Image (next/image)

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

No response

@sensedrive sensedrive added the bug Issue was opened via the bug report template. label May 7, 2024
@github-actions github-actions bot added the Image (next/image) Related to Next.js Image Optimization. label May 7, 2024
@sensedrive sensedrive changed the title Property overrideSrc of image component (next/image) does not work Property overrideSrc of image component (next/image) does not override srcset property May 7, 2024
@akashMasih
Copy link

In Next.js, the next/image component is used for optimizing image loading and providing a better user experience. One of its properties is overrideSrc, which allows you to override the src attribute of the img tag generated by the next/image component. However, the overrideSrc property does not override the srcset property.

@sensedrive
Copy link
Author

Right ... after reading the docs a third time ( overrideSrc ) I admit this is expected behaviour.

But is there any way to manage not exposing tokens, or sensitive data ... especially when loading images from a secured endpoint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.
Projects
None yet
Development

No branches or pull requests

2 participants