nextjs - ✅(Solved) Fix experimental.sri: integrity mismatch blocks scripts when served via CDN/edge cache [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#91633Fetched 2026-04-08 01:01:26
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
subscribed ×3commented ×1

PR fix notes

PR #354: docs: add SocialShareButton tutorial video to README

Description (problem / solution / changelog)

Tutorial: SocialShareButton Integration with Resonate Website

Closes #19 (AOSSIE-Org/SocialShareButton)

Added SocialShareButton to the Resonate landing page footer.

🎬 Demo Video: https://drive.google.com/file/d/12gu3D8wuIiDhwZvS12MaiEfg6CFZGTMv/view?usp=sharing

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit

  • New Features

    • Added a styled social share button to the website footer with interactive hover effects.
    • Integrated third-party social sharing library to enable sharing functionality.
  • Documentation

    • Added a "Project Demo" section in the README with a demo video walkthrough.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Changed files

  • README.md (modified, +5/-0)
  • app/components/Layout/Footer/Footer.css (modified, +14/-0)
  • app/components/Layout/Footer/index.jsx (modified, +21/-2)
  • app/layout.js (modified, +17/-1)

Code Example

Failed to find a valid digest in the 'integrity' attribute for resource
'https://styled-components.com/_next/static/chunks/turbopack-0w~tdqgwj6w-f.js'
with computed SHA-256 integrity 'AtgbquOIdxzkrCKl+OJ4ftygSY0ED3Ynyy6vxt1C468='.
The resource has been blocked.

---

Next.js 16.2.0 (Turbopack)
Node.js 22.x
Deployed on Vercel
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/styled-components/styled-components-website

To Reproduce

  1. Enable experimental: { sri: { algorithm: 'sha256' } } in next.config.mjs
  2. Deploy to Vercel (or any CDN with edge caching)
  3. Load the site in a browser

Current vs. Expected behavior

Current: Browser blocks scripts with errors like:

Failed to find a valid digest in the 'integrity' attribute for resource
'https://styled-components.com/_next/static/chunks/turbopack-0w~tdqgwj6w-f.js'
with computed SHA-256 integrity 'AtgbquOIdxzkrCKl+OJ4ftygSY0ED3Ynyy6vxt1C468='.
The resource has been blocked.

Expected: Integrity hashes should match the served content, or SRI should account for CDN transformations (compression, encoding) that alter the byte stream between build-time hashing and browser receipt.

Provide environment information

Next.js 16.2.0 (Turbopack)
Node.js 22.x
Deployed on Vercel

Which area(s) are affected?

SRI / Security

Additional context

Likely related to #74147 and #74149. The hash is generated at build time against the raw chunk, but the CDN may serve a differently-encoded version (e.g., Brotli/gzip content-encoding differences, or edge transformations). Disabling experimental.sri resolves the issue.

extent analysis

Fix Plan

To resolve the Subresource Integrity (SRI) issue with Next.js and Vercel, we need to ensure that the integrity hashes match the served content, taking into account CDN transformations.

Step-by-Step Solution

  • Disable experimental.sri: Temporarily disable SRI in next.config.mjs to verify that the issue is indeed related to SRI.
  • Use a custom getStaticProps: Implement a custom getStaticProps function to generate the integrity hash after CDN transformations.
  • Generate hash after compression: Use a library like zlib to compress the content and generate the hash.

Example code:

// next.config.mjs
module.exports = {
  experimental: {
    // Disable SRI temporarily
    // sri: { algorithm: 'sha256' }
  }
}

// pages/_app.js
import { useState, useEffect } from 'react';
import zlib from 'zlib';

function MyApp({ Component, pageProps }) {
  const [integrityHash, setIntegrityHash] = useState('');

  useEffect(() => {
    const chunk = '_next/static/chunks/turbopack-0w~tdqgwj6w-f.js';
    fetch(chunk)
      .then(response => response.arrayBuffer())
      .then(arrayBuffer => {
        const compressedBuffer = zlib.gzipSync(arrayBuffer);
        const hash = crypto.createHash('sha256');
        hash.update(compressedBuffer);
        setIntegrityHash(hash.digest('base64'));
      });
  }, []);

  return (
    <div>
      <script
        src="_next/static/chunks/turbopack-0w~tdqgwj6w-f.js"
        integrity={`sha256-${integrityHash}`}
        crossOrigin="anonymous"
      />
      <Component {...pageProps} />
    </div>
  );
}

Verification

Verify that the integrity hash is generated correctly and matches the served content by checking the browser console for any SRI-related errors.

Extra Tips

  • Ensure that the zlib library is installed and imported correctly.
  • Consider using a more robust solution, such as using a library like subresource-integrity to generate the integrity hash.
  • Keep in mind that this is a temporary workaround, and a more permanent solution may be required to address the underlying issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix experimental.sri: integrity mismatch blocks scripts when served via CDN/edge cache [1 pull requests, 1 comments, 2 participants]