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

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

Open
5 tasks done
CrypticSignal opened this issue Oct 20, 2023 · 2 comments

Comments

@CrypticSignal
Copy link

CrypticSignal commented Oct 20, 2023

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • 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 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

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

Build Settings

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.

@CrypticSignal
Copy link
Author

Any update on this?

@lucasgjorge
Copy link

You should try adding the credentiallesss attribute to your tag, it might work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants