William Jin
William Jin
WWasp
Created by William Jin on 12/19/2024 in #🙋questions
Manipulating production database with fly.io and wasp db studio
@kapa.ai I used the Wasp CLI to deployed my db (skyblaze-db). I followed the tutorial by: Run fly proxy 5432 -a skyblaze-db and got Proxying local port 5432 to remote [skyblaze-db.internal]:5432 Put DATABASE_URL in my .env.server: DATABASE_URL=postgres://postgres:<password>@localhost:5432/skyblaze-db However I got
❌ --- [Error] Can not connect to database: ---------------------------------------

The database needs to be running in order to execute this command. You can easily start a managed dev database with `wasp start db`.
❌ --- [Error] Can not connect to database: ---------------------------------------

The database needs to be running in order to execute this command. You can easily start a managed dev database with `wasp start db`.
When I run wasp db studio. My question is: 1. is the database password something I got when first deployed to fly.io, with 15 characters? I got the message
Postgres cluster skyblaze-db is now attached to skyblaze-server
The following secret was added to skyblaze-server:
DATABASE_URL=postgres://skyblaze_server:<credential>@skyblaze-db.flycast:5432/skyblaze_server?sslmode=disable
Please take note of your database credentials above, as they will not be available in plaintext again. Press any key to continue.
Postgres cluster skyblaze-db is now attached to skyblaze-server
The following secret was added to skyblaze-server:
DATABASE_URL=postgres://skyblaze_server:<credential>@skyblaze-db.flycast:5432/skyblaze_server?sslmode=disable
Please take note of your database credentials above, as they will not be available in plaintext again. Press any key to continue.
2. If so, which sould be correct? DATABASE_URL=postgres://postgres:<credential>@localhost:5432/skyblaze-db or DATABASE_URL=postgres://skyblaze_server:<credential>@skyblaze-db.flycast:5432/skyblaze_server?sslmode=disable 3. How should I fix the
❌ --- [Error] Can not connect to database: ---------------------------------------

The database needs to be running in order to execute this command. You can easily start a managed dev database with `wasp start db`.
❌ --- [Error] Can not connect to database: ---------------------------------------

The database needs to be running in order to execute this command. You can easily start a managed dev database with `wasp start db`.
? Thanks!
16 replies
WWasp
Created by William Jin on 12/18/2024 in #🙋questions
Getting CORS issue when using Wasp CLI to deploy
@kapa.ai I'm experiencing a CORS issue, NOT using my own domain:
Access to XMLHttpRequest at 'https://skyblaze-server.fly.dev/crud/Slot/get-all' from origin 'https://skyblaze-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://skyblaze-server.fly.dev/crud/Slot/get-all' from origin 'https://skyblaze-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 main.wasp is like
server: {
setupFn: import setup from "@src/serverSetup",
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
server: {
setupFn: import setup from "@src/serverSetup",
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
And my src/serverSetup.ts:
import bodyParser from 'body-parser';
import cors from 'cors';
import { type MiddlewareConfigFn } from 'wasp/server';

export default function setup() {
console.log('Server setup running...');
}

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
middlewareConfig.set('express.json', bodyParser.json({ limit: '10mb' }));
middlewareConfig.set('cors', cors({ origin: ['http://localhost:3000', 'https://skyblaze-client.fly.dev'] }));
return middlewareConfig;
};
import bodyParser from 'body-parser';
import cors from 'cors';
import { type MiddlewareConfigFn } from 'wasp/server';

export default function setup() {
console.log('Server setup running...');
}

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
middlewareConfig.set('express.json', bodyParser.json({ limit: '10mb' }));
middlewareConfig.set('cors', cors({ origin: ['http://localhost:3000', 'https://skyblaze-client.fly.dev'] }));
return middlewareConfig;
};
(My client URL is https://skyblaze-client.fly.dev). Seems the CORS settings do work on my local machine since when I removed http://localhost:3000, it also throws a CORS error locally. I'm wondering whether there're something wrong in my serverSetup and middleware that causing this issue?
43 replies