How to hide next.js version from tools like Wappanalyzer #68058
-
SummaryHi I want to hide next.js version from Wappanalyzer, but even with: ...
const nextConfig = {
poweredByHeader: false,
... it removed it from header, but still available in detecting version. Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
I am guessing that, they are probably using I ran grep -rl '14.2.5' .next/static/chunks | xargs sed -i '' 's/14.2.5/xx.xx.xx/g' Then used I the code above, and It might not be enough though, maybe Wappalyzer check the files names |
Beta Was this translation helpful? Give feedback.
-
Thanks to @ivanafanasyeu’s solution I was able to remove the Next.js version successfully. Improvements I made
Final solution
#!/bin/sh
set -e
echo "[postbuild] Stripping Next.js version from .next artifacts for security…"
# Get the actual installed Next.js version
NEXT_VERSION=$(node -p "require('./node_modules/next/package.json').version" 2>/dev/null || echo "")
if [ -z "$NEXT_VERSION" ]; then
echo "[postbuild] ⚠️ Could not detect Next.js version. Skipping strip step."
exit 0
fi
# Find all files containing the version
FILES=$(grep -rlF "$NEXT_VERSION" .next || true)
if [ -z "$FILES" ]; then
echo "[postbuild] ✅ No occurrences of $NEXT_VERSION found in .next."
exit 0
fi
# Replace version with empty string
echo "$FILES" | xargs sed -i "s/$NEXT_VERSION//g"
echo "[postbuild] ✅ Removed Next.js version $NEXT_VERSION from $(echo "$FILES" | wc -l) files."
chmod +x scripts/strip-next-version.sh
"scripts": {
"build": "next build --turbopack",
"postbuild": "./scripts/strip-next-version.sh",
}, If everything works correctly, you’ll see output like this after the build:
Note 1: If your team works on different OSs (especially Windows) you may need to handle executable permission more gracefully. Like this: git add --chmod=+x scripts/strip-next-version.sh Note 2: These commands and scripts are written for the Bash shell, if you use other shells you may need to update accordingly. I personally use the Fish shell and haven’t encountered any issues. |
Beta Was this translation helpful? Give feedback.
I found a way, for more precise removing:
do it after the build step