Open darthmaim opened 4 months ago
Adding export const runtime = 'edge';
to the page will correctly output integrity attributes, so I guess the issue is only with the node.js runtime and related to the following comment in the test:
// Currently webpack chunks loaded via flight runtime do not get integrity
// hashes. This was previously unobservable in this test because these scripts
// are inserted by the webpack runtime and immediately removed from the document.
// However with the advent of preinitialization of chunks used during SSR there are
// some script tags for flight loaded chunks that will be part of the initial HTML
// but do not have integrity hashes. Flight does not currently support a way to
// provide integrity hashes for these chunks. When this is addressed in React upstream
// we can revisit this tests assertions and start to ensure it actually applies to
// all SSR'd scripts. For now we will look for known entrypoint scripts and assume
// everything else in the <head> is part of flight loaded chunks
I wonder if this is fixed in react by now (the comment was added Aug 30, 2023 in #54752), and if not, what is missing in react, and if there is a tracking issue in the react repo.
Now supported in Safari 18 https://webkit.org/blog/15865/webkit-features-in-safari-18-0/
WebKit for Safari 18.0 adds support for subresource integrity in imported module scripts, which gives cryptographic assurances about the integrity of contents of externally-hosted module scripts.
Link to the code that reproduces this issue
https://github.com/darthmaim-reproductions/vercel-next.js-66901
To Reproduce
npm run build && npm run start
Current vs. Expected behavior
Current No
integrity
attribute present on any<script>
Expected
integrity
attribute added to<script>
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next start (local), Other (Deployed)
Additional context
The only change to the reproduction template was adding this config to
next.config.mjs
:There is a test (https://github.com/vercel/next.js/tree/canary/test/production/app-dir/subresource-integrity) that is supposed to test this, which has the same config as my reproduction repository, but I was not able to get SRI working.
There is a
.next/server/subresource-integrity-manifest.json
file generated which contains all the correct hashes.