linus
linus
WWasp-lang
Created by linus on 10/14/2024 in #đŸ™‹questions
CORS issue
Hi I can't get around this error in production:
Access to XMLHttpRequest at 'https://skyber-academy-server.fly.dev/operations/get-waitlist-emails' from origin 'https://skyber-academy-client.fly.dev' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to XMLHttpRequest at 'https://skyber-academy-server.fly.dev/operations/get-waitlist-emails' from origin 'https://skyber-academy-client.fly.dev' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
my app/src/server/utils.ts:
import cors from 'cors';
import { type MiddlewareConfigFn } from 'wasp/server';

export function requireNodeEnvVar(name: string): string {
const value = process.env[name];
if (value === undefined) {
throw new Error(`Env var ${name} is undefined`);
} else {
return value;
}
}

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// @ts-ignore
middlewareConfig.set('cors', cors({ origin: [process.env.WASP_WEB_CLIENT_URL, 'http://localhost:3000'] }));
return middlewareConfig;
};
import cors from 'cors';
import { type MiddlewareConfigFn } from 'wasp/server';

export function requireNodeEnvVar(name: string): string {
const value = process.env[name];
if (value === undefined) {
throw new Error(`Env var ${name} is undefined`);
} else {
return value;
}
}

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// @ts-ignore
middlewareConfig.set('cors', cors({ origin: [process.env.WASP_WEB_CLIENT_URL, 'http://localhost:3000'] }));
return middlewareConfig;
};
my main.wasp:
app SkyberAcademy {
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/server/utils"
},
}
app SkyberAcademy {
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/server/utils"
},
}
I deployed using wasp deploy fly deploy
16 replies
WWasp-lang
Created by linus on 9/15/2024 in #đŸ™‹questions
How do I connect to the postgres db deployed on fly?
I deployed my aspp using wasp deploy fly deploy and i want to see the data in the db, how can I do that?
8 replies
WWasp-lang
Created by linus on 9/9/2024 in #đŸ™‹questions
Trouble with forms...
No description
8 replies