Yisacc - Full Stack Dev
Yisacc - Full Stack Dev
SSolidJS
Created by Yisacc - Full Stack Dev on 3/18/2024 in #support
Cannot find module
When running unit test am facing this error
Error: Cannot find module '.../node_modules/.pnpm/@[email protected][email protected]/node_modules/@solidjs/router/dist/integration' imported from /node_modules/.pnpm/@[email protected][email protected]/node_modules/@solidjs/router/dist/routing.js
Error: Cannot find module '.../node_modules/.pnpm/@[email protected][email protected]/node_modules/@solidjs/router/dist/integration' imported from /node_modules/.pnpm/@[email protected][email protected]/node_modules/@solidjs/router/dist/routing.js
here is my vitest.config.ts configuration
export default mergeConfig(viteConfig, defineConfig({
test: {
setupFiles: [
"./tests/init.ts",
],
environment: "jsdom",
globals: true,
threads: false,
isolate: false,
includeSource: ["src/**/*.{js,ts,tsx,jsx}"],
transformMode: {
web: [/\.[jt]sx?$/],
},
open: false,
},
resolve: {
conditions: ["development", "browser"],
},
}));
export default mergeConfig(viteConfig, defineConfig({
test: {
setupFiles: [
"./tests/init.ts",
],
environment: "jsdom",
globals: true,
threads: false,
isolate: false,
includeSource: ["src/**/*.{js,ts,tsx,jsx}"],
transformMode: {
web: [/\.[jt]sx?$/],
},
open: false,
},
resolve: {
conditions: ["development", "browser"],
},
}));
39 replies
SSolidJS
Created by Yisacc - Full Stack Dev on 9/24/2023 in #support
catch 401 error in entry server
async function preProcessor(forward: MiddlewareFn, event: FetchEvent, session: Session) {
const response = await forward(event);
console.log("status", response.status);
if (response.status === 401) {
return redirect("/", {
headers: {
"Set-Cookie": await storage.destroySession(session),
},
});
}
return response;
}
async function preProcessor(forward: MiddlewareFn, event: FetchEvent, session: Session) {
const response = await forward(event);
console.log("status", response.status);
if (response.status === 401) {
return redirect("/", {
headers: {
"Set-Cookie": await storage.destroySession(session),
},
});
}
return response;
}
({ forward }) => {
return async (event) => {
const pathname = new URL(event.request.url).pathname;
const isApiPath = pathname.startsWith("/api") || pathname.startsWith("/_m");
const session = await getSession(event.request.headers.get("Cookie"));
if (isApiPath) {
return await preProcessor (forward, event, session);
}
})
({ forward }) => {
return async (event) => {
const pathname = new URL(event.request.url).pathname;
const isApiPath = pathname.startsWith("/api") || pathname.startsWith("/_m");
const session = await getSession(event.request.headers.get("Cookie"));
if (isApiPath) {
return await preProcessor (forward, event, session);
}
})
I am trying to destroy sessions and redirect to sign in page on 401 console.log is logging 401 but it is not either being redirected or the session destroy
1 replies