Closed zishanaxioned closed 2 months ago
Hello, @zishanaxioned and sorry to hear you're running into this. The more I look into this, the more it seems like it's an issue related to Amplify Hosting rather than any specific library API or JS related error.
I'll reference the note that's at the top of the amplify-hosting
repo's README (here). It states:
For technical support, we encourage you to open a case with AWS technical support if you have AWS support plan. If you do not have an active AWS support plan, we encourage you to leverage our Amplify community Discord server where community members and staff try to help each other with Amplify.
So while I'll close this issue down on the JS repo, we and other members of the community can assist your further within an "amplify-help" thread on our Discord server. Alternatively, the AWS Support team can assist as well.
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Storage
Amplify Version
v6
Amplify Categories
No response
Backend
None
Environment information
Describe the bug
I encountered an issue with the image optimization process on AWS Amplify for a Next.js project. When specifying a pathname in the remotePatterns configuration within next.config.js, Amplify is not respecting the specified rules. This is causing unintended behavior where images from any Contentful space are processed, even if they do not match the specified pathname.
Configuration: Here's the relevant part of my next.config.js:
Actual Behaviour: On AWS Amplify, the rule is not being applied as expected. Instead, the optimization process is allowing images from any Contentful space to be processed, which could lead to potential forgery issues. For example, an image URL like https://xyz.com/_next/image?url=https://images.ctfassets.net/OTHER_SPACE_ID/image.png is processed, even though it should be restricted to my specified Contentful space.
Expected behavior
The image optimization should only process images from the specified Contentful space, as defined by process.env.NEXT_PUBLIC_CONTENTFUL_SPACE_ID. This behavior works correctly when deployed on Vercel.
Reproduction steps
Additional Context: This issue seems specific to AWS Amplify, as the same configuration works as expected on Vercel, where only the images from the specified Contentful space are processed.
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
The above image is not coming from my contentful space but is hosted somewhere else. But the user can pretent that it is coming from my site which might be valid and tricky to normal users.
Note: The site url is not the exact URL but you can replicate it at your end