mardi 4 août 2020

When set custom header , why the script tag request throw cross origin error in puppeteer?

In puppeteer set Custome header:

  await page.setExtraHTTPHeaders({
    'X-ENV': 'test'
  })

Open a Page in Puppeteer, the tidy html code below:

<body>
    <script src="xxxxx/static/js/main.87874446.chunk.js" crossorigin="anonymous">
</body>

and the puppeteer will throw error:

Access to script at 'xxxxx/static/js/main.87874446.chunk.js' from origin 'xxxxx' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

why the script tag resource need set the cors?




Aucun commentaire:

Enregistrer un commentaire