Skip to content

Commit b217456

Browse files
committed
test: add fixture hitting limitation
1 parent ece6b5d commit b217456

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const metadata = {
2+
title: 'Simple Next App',
3+
description: 'Description for Simple Next App',
4+
}
5+
6+
export default function RootLayout({ children }) {
7+
return (
8+
<html lang="en">
9+
<body>{children}</body>
10+
</html>
11+
)
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function Home() {
2+
return (
3+
<main>
4+
<h1>Home</h1>
5+
</main>
6+
)
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// bcrypt is using C++ Addons (.node binaries) which are unsupported currently
2+
// example copied from https://nextjs.org/blog/next-15-2#nodejs-middleware-experimental
3+
import bcrypt from 'bcrypt'
4+
5+
const API_KEY_HASH = process.env.API_KEY_HASH // Pre-hashed API key in env
6+
7+
export default async function middleware(req) {
8+
const apiKey = req.headers.get('x-api-key')
9+
10+
if (!apiKey || !(await bcrypt.compare(apiKey, API_KEY_HASH))) {
11+
return new Response('Forbidden', { status: 403 })
12+
}
13+
14+
console.log('API key validated')
15+
}
16+
17+
export const config = {
18+
runtime: 'nodejs',
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
output: 'standalone',
4+
eslint: {
5+
ignoreDuringBuilds: true,
6+
},
7+
experimental: {
8+
nodeMiddleware: true,
9+
},
10+
outputFileTracingRoot: __dirname,
11+
}
12+
13+
module.exports = nextConfig
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "middleware-node-unsupported-cpp-addons",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"postinstall": "next build",
7+
"dev": "next dev",
8+
"build": "next build"
9+
},
10+
"dependencies": {
11+
"bcrypt": "^6.0.0",
12+
"next": "latest",
13+
"react": "18.2.0",
14+
"react-dom": "18.2.0"
15+
},
16+
"test": {
17+
"dependencies": {
18+
"next": ">=15.2.0"
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)