⨯ ./node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>
Import trace for requested module:
./node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
./node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/ sync ^\.\/.*$
./node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js
./node_modules/.pnpm/bcrypt@5.1.1/node_modules/bcrypt/bcrypt.js
./src/lib/auth/provider.ts
./src/lib/auth/utils.ts
⚠ ./node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js
Module not found: Can't resolve 'npm' in 'D:\panel\node_modules\.pnpm\@mapbox+node-pre-gyp@1.0.11\node_modules\@mapbox\node-pre-gyp\lib\util'
#middleware bcrypt
24 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
middleware run on edge runtime which does not support bcrypt
ok now I'm using bcryptjs now this comes:
node_modules\.pnpm\redis-errors@1.2.0\node_modules\redis-errors\index.js (3:0) @ <unknown>
⨯ Cannot read properties of undefined (reading 'charCodeAt')
null
○ Compiling /not-found ...
✓ Compiled /not-found in 775ms (395 modules)
⚠ Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/messages/fast-refresh-reload
⨯ node_modules\.pnpm\redis-errors@1.2.0\node_modules\redis-errors\index.js (3:0) @ <unknown>
⨯ Cannot read properties of undefined (reading 'charCodeAt')
null
⨯ node_modules\.pnpm\redis-errors@1.2.0\node_modules\redis-errors\index.js (3:0) @ <unknown>
⨯ Cannot read properties of undefined (reading 'charCodeAt')
null
are you using redis for nodejs?
yes I'm using ioredis
which require node api
are you using next-auth and want to handle authorization in middelware
no
ok
I want to handle auth in middleware but using a custom system
export const validateSession = async (): Promise<User | null> => {
const cookie = cookies().get("SESSION");
if (cookie === undefined) {
return null;
}
const sessionId = cookie.value;
if (!validator.isUUID(sessionId)) {
return null;
}
const redis = createRedisInstance();
const session = await redis.get(`session:${sessionId}`);
if (session === null) {
return null;
}
let userId = Number(session);
if (isNaN(userId)) {
return null;
}
const userInfo = await AUTH.info(userId);
if (userInfo === null) {
return null;
}
return {
id: userId,
email: userInfo.email,
username: userInfo.username,
first_name: userInfo.first_name,
last_name: userInfo.last_name,
};
};
middleware:
export async function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith("/sign-in")) return;
const user = validateSession();
if (user === null)
NextResponse.redirect("/sign-in", {
status: 302,
});
}
can you turn validateSession to a route handler and try to fetch it in middleware?
or use upstash redis
yeah worked but now when I redirect the styles are gone
redirect from middleware?
yeah
does refresh show the style?
ok nvm the styles are completely gone