Open ccfai8 opened 3 weeks ago
I am trying to use middleware to redirect non subscriber to signin back. The middleware changes work for Vercel but not work on Coolify.
// middleware.ts import { NextResponse } from 'next/server';
export async function middleware(request: Request) { const response = await fetch(new URL('/api/check-subscription', request.url), { headers: request.headers, credentials: 'same-origin', });
const data = await response.json();
if (response.ok && data.hasAccess) { return NextResponse.next(); } else { return NextResponse.redirect(new URL('/signin', request.url)); } }
export const config = { matcher: ['/docs/:path*'], };
at l.with (/app/.next/server/src/middleware.js:13:31961) at l.startActiveSpan (/app/.next/server/src/middleware.js:13:47013) {
cause: [Error: 406CE0B557760000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:354: ] { library: 'SSL routines', reason: 'wrong version number', code: 'ERR_SSL_WRONG_VERSION_NUMBER' } } Error: fetch failed at context.fetch (/app/node_modules/next/dist/server/web/sandbox/context.js:292:38) at Object.eV [as handler] (/app/.next/server/src/middleware.js:13:26016) at /app/.next/server/src/middleware.js:13:24843 at AsyncLocalStorage.run (node:async_hooks:338:14) at Object.wrap (/app/.next/server/src/middleware.js:13:22130) at /app/.next/server/src/middleware.js:13:24656 at /app/.next/server/src/middleware.js:13:19434 at i.with (/app/.next/server/src/middleware.js:13:37761) at l.with (/app/.next/server/src/middleware.js:13:31961) at l.startActiveSpan (/app/.next/server/src/middleware.js:13:47013) { cause: [Error: 406CE0B557760000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:354: ] { library: 'SSL routines', reason: 'wrong version number', code: 'ERR_SSL_WRONG_VERSION_NUMBER' } }
14.2.3
Will that be possible that the API URL is causing the error?
Description
I am trying to use middleware to redirect non subscriber to signin back. The middleware changes work for Vercel but not work on Coolify.
Minimal Reproduction (if possible, example repository)
// middleware.ts import { NextResponse } from 'next/server';
export async function middleware(request: Request) { const response = await fetch(new URL('/api/check-subscription', request.url), { headers: request.headers, credentials: 'same-origin', });
const data = await response.json();
if (response.ok && data.hasAccess) { return NextResponse.next(); } else { return NextResponse.redirect(new URL('/signin', request.url)); } }
export const config = { matcher: ['/docs/:path*'], };
Exception or Error
cause: [Error: 406CE0B557760000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:354: ] { library: 'SSL routines', reason: 'wrong version number', code: 'ERR_SSL_WRONG_VERSION_NUMBER' } } Error: fetch failed at context.fetch (/app/node_modules/next/dist/server/web/sandbox/context.js:292:38) at Object.eV [as handler] (/app/.next/server/src/middleware.js:13:26016) at /app/.next/server/src/middleware.js:13:24843 at AsyncLocalStorage.run (node:async_hooks:338:14) at Object.wrap (/app/.next/server/src/middleware.js:13:22130) at /app/.next/server/src/middleware.js:13:24656 at /app/.next/server/src/middleware.js:13:19434 at i.with (/app/.next/server/src/middleware.js:13:37761) at l.with (/app/.next/server/src/middleware.js:13:31961) at l.startActiveSpan (/app/.next/server/src/middleware.js:13:47013) { cause: [Error: 406CE0B557760000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:354: ] { library: 'SSL routines', reason: 'wrong version number', code: 'ERR_SSL_WRONG_VERSION_NUMBER' } }
Version
14.2.3