aws-amplify / aws-amplify/amplify-hosting

Because your site has the Cross-Origin Embedder Policy enabled, each embedded iframe must also specify this policy

Open
#3,766 3 comments 0 reactions 0 assignees View on GitHub
pending-triage
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:

![image](https://github.com/aws-amplify/amplify-hosting/assets/48166845/1cf5ca7d-e6cd-4dcb-a0c0-ba173396d755)

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:

![image](https://github.com/aws-amplify/amplify-hosting/assets/48166845/0542bf28-a7eb-4cee-b1f0-d7236b2c2df1)

### 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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.