Is there a way to implement Subresource Integrity Check for Next.js? Either Next 12, 13, or 14?

187 Views Asked by At

Enabling experimental sri module.

experimental: {
    sri: {
      algorithm: 'sha256'
    }
  },

It generates the subresource integrity manifest files, but doesn't inject the integrity attribute within the build.

We were expecting to see an integrity attribute within the script tag. For Example:

<script integrity="kjkdjkdjkjaaaldks="/>

but was getting within the built html

<script />
1

There are 1 best solutions below

0
schlumpf On

I had the same question, unfortunately it is not possible to have SRI on the scripts that next js generated by itself. I cite: "Currently webpack chunks loaded via flight runtime do not get integrity hashes."