aws-amplify / aws-amplify/amplify-hosting
Because your site has the Cross-Origin Embedder Policy enabled, each embedded iframe must also specify this policy
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### App Id
d2hzcewjwit905
### AWS Region
eu-west-2
### Amplify Hosting feature
CDK, Custom headers
### Frontend framework
Next.js
### Next.js version
13.5.6
### Next.js router
App Router
### Describe the bug
My Next.js 13 app (https://main.d2hzcewjwit905.amplifyapp.com/) which uses [ffmpeg.wasm](https://github.com/ffmpegwasm/ffmpeg.wasm) tries to make a request to https://main.d2hzcewjwit905.amplifyapp.com/_next/static/chunks/795.ceab62a43c56068c.js when trying to convert a file. You can see this in the network tab. This gives the following error:

I'm not sure how to resolve this. I have set `Cross-Origin-Embedder-Policy` to `require-corp` for all paths in `next.config.js` (unless `source: "/(.*)"` doesn't match all paths? I tried `source: "/"` too and got the same issue).
The source code for my project which includes my `next.config.js` file can be found here: https://github.com/CrypticSignal/av-converter-amplify
### Expected behavior
I was expecting no COEP related issues as I have set the following in `next.config.js`:
```
async headers() {
return [
{
source: "/(.*)",
headers: [
{
key: "Cross-Origin-Embedder-Policy",
value: "require-corp",
},
{
key: "Cross-Origin-Opener-Policy",
value: "same-origin",
},
{
key: "Access-Control-Allow-Origin",
value: "*",
},
],
},
];
},
```
### Reproduction steps
1. Go to https://main.d2hzcewjwit905.amplifyapp.com
2. Open devtools and go to the network tab
3. Try to convert a file
4. After a few seconds, you should see a request being made to https://main.d2hzcewjwit905.amplifyapp.com/_next/static/chunks/795.ceab62a43c56068c.js and the following error:

### Build Settings
```yaml
version: 1
frontend:
phases:
build:
commands:
- yarn install
- yarn build
artifacts:
baseDirectory: .next
files:
- "**/*"
cache:
paths:
- node_modules/**/*
```
### Additional information
Platform: Web compute
The vercel deployed version works: https://av-converter-amplify.vercel.app
Therefore, Amplify and/or CloudFront is definitely the cause of the issue with the Amplify hosted version: https://main.d2hzcewjwit905.amplifyapp.com
I have also deployed a regular React version which doesn't use Next.js (https://main.d18xlq54508lji.amplifyapp.com) to check whether the issue is Next.js related. I get the same issue so the issue is not related to Next.js but rather caused by Amplify and/or CloudFront.
Contributor guide
Research direction
Start by reproducing the COEP error on the linked Amplify deployment and compare it with the working Vercel deployment. Inspect the linked project's next.config.js and the reported Amplify custom-header and Web Compute settings; done should identify whether Amplify or CloudFront is responsible and document a verified resolution or limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, next.js, react
- Domain
- cloud, frontend, infrastructure
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100