mgp25
mgp25
WWasp
Created by mgp25 on 2/11/2025 in #🙋questions
Missing migrations
- Wasp version: 0.13.x I have an instance were it seems it is missing the migrations files, so when running in prod, wasp db migrate-dev we face the following issue:
🐝 --- Starting database migration... ---------------------------------------------

Environment variables loaded from .env
Prisma schema loaded from ../db/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "127.0.0.1:5432"

Drift detected: Your database schema is not in sync with your migration history.

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.

It should be understood as the set of changes to get from the expected schema to the actual schema.

...
...
...

✔ We need to reset the "public" schema at "127.0.0.1:5432"
Do you want to continue? All data will be lost. … no
🐝 --- Starting database migration... ---------------------------------------------

Environment variables loaded from .env
Prisma schema loaded from ../db/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "127.0.0.1:5432"

Drift detected: Your database schema is not in sync with your migration history.

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.

It should be understood as the set of changes to get from the expected schema to the actual schema.

...
...
...

✔ We need to reset the "public" schema at "127.0.0.1:5432"
Do you want to continue? All data will be lost. … no
I have already tried wasp clean and running wasp db migrate-dev, but the same problems remains. I have also tried removing the migration from:
DELETE FROM _prisma_migrations WHERE migration_name = '20241128215415_';
DELETE FROM _prisma_migrations WHERE migration_name = '20241128215415_';
Same problem is happening. And yes, keeping data is a must. Any idea how to solve this? Thank you!
11 replies
WWasp
Created by mgp25 on 2/9/2025 in #🙋questions
Configure timeout/exceptions for actions
Wasp version: 0.13.x So I have this situation where an action takes so much time that the connection closes because what I believe a timeout, and that is completely fine for me, however I would be able to properly control those exceptions when calling an action fails for whatever reason. Is there any way to do this? Right now I am getting the message Network Error. While this might work:
catch (err: any) {
if (err.message === "Network Error"){
catch (err: any) {
if (err.message === "Network Error"){
It is not a proper solution, since there are many different causes of a Network Error. Thank you
7 replies
WWasp
Created by mgp25 on 2/9/2025 in #🙋questions
auth/me delivering too much info to client
Wasp version: 0.13.x I am seeing the requests /auth/me and it returns too much info to client. I haven't seen anywhere to limit the info provided to client or at least in a more clean way. Thank you
6 replies
WWasp
Created by mgp25 on 2/4/2025 in #🙋questions
CORS issue - wasp 0.13
Basically we are getting a lot of CORS issues, such as:
Failed to load resource: the server responded with a status of 401 ()
Origin https://wislearn.io is not allowed by Access-Control-Allow-Origin. Status code: 504
XMLHttpRequest cannot load https://api.wislearn.io/operations/process-task due to access control checks.
Failed to load resource: the server responded with a status of 401 ()
Origin https://wislearn.io is not allowed by Access-Control-Allow-Origin. Status code: 504
XMLHttpRequest cannot load https://api.wislearn.io/operations/process-task due to access control checks.
The following is in main.wasp:
wasp: {
version: "^0.13.2"
},
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
wasp: {
version: "^0.13.2"
},
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
And serverSetup.ts content is:
import cors from 'cors'
import { config, type MiddlewareConfigFn } from 'wasp/server'

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Set up CORS with allowed origins
middlewareConfig.set('cors', cors({ origin: [config.frontendUrl, 'https://api.wislearn.io', 'https://wislearn.io'] }));

return middlewareConfig;
};
import cors from 'cors'
import { config, type MiddlewareConfigFn } from 'wasp/server'

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Set up CORS with allowed origins
middlewareConfig.set('cors', cors({ origin: [config.frontendUrl, 'https://api.wislearn.io', 'https://wislearn.io'] }));

return middlewareConfig;
};
Pretty much as the guides and other examples shows. Any idea what could be happening? Best regards
7 replies
WWasp
Created by mgp25 on 11/28/2024 in #🙋questions
CORS Issue
Wasp version: 0.13.2 Backend: https://api.mydomain.com I have read other issues regarding CORS and I have deployed everything as the documentation recommends: I have a serverSetup.ts file which has the following:
import cors from 'cors'
import { config, type MiddlewareConfigFn } from 'wasp/server'

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('cors', cors({ origin: [config.frontendUrl, 'https://mydomain.com'] }))
return middlewareConfig
}
import cors from 'cors'
import { config, type MiddlewareConfigFn } from 'wasp/server'

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('cors', cors({ origin: [config.frontendUrl, 'https://mydomain.com'] }))
return middlewareConfig
}
As far as I know config.frontendUrl should be already https://mydomain.com but I have added since I am not able to get it working. In main.wasp I have added the following:
wasp: {
version: "^0.13.2"
},
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
wasp: {
version: "^0.13.2"
},
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
But I am still getting on client:
[Error] XMLHttpRequest cannot load https://api.mydomain.com/auth/me due to access control checks.
[Error] Failed to load resource: Origin https://mydomain.com is not allowed by Access-Control-Allow-Origin. Status code: 404 (me, line 0)
[Error] XMLHttpRequest cannot load https://api.mydomain.com/auth/me due to access control checks.
[Error] Failed to load resource: Origin https://mydomain.com is not allowed by Access-Control-Allow-Origin. Status code: 404 (me, line 0)
NGINX config:
location / {
proxy_pass http://localhost:3001; # Forward requests to the backend server
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
location / {
proxy_pass http://localhost:3001; # Forward requests to the backend server
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
Any idea what I am missing?
12 replies
WWasp
Created by mgp25 on 11/21/2024 in #🙋questions
Question about shared constants
We have the following code in shared constants:
const isDevEnv = process.env.NODE_ENV !== 'production';
const customerPortalTestUrl = 'TEST_URL';
const customerPortalProdUrl = 'PROD_URL';

export const STRIPE_CUSTOMER_PORTAL_LINK = isDevEnv
? customerPortalTestUrl
: customerPortalProdUrl;
const isDevEnv = process.env.NODE_ENV !== 'production';
const customerPortalTestUrl = 'TEST_URL';
const customerPortalProdUrl = 'PROD_URL';

export const STRIPE_CUSTOMER_PORTAL_LINK = isDevEnv
? customerPortalTestUrl
: customerPortalProdUrl;
When testing locally, I am seeing the file constants is fetched as it is, being able to see test url as well. Is this the expected behaviour? Is there any better way to be able to set these while keeping the test url hidden during the deploy?
21 replies
WWasp
Created by mgp25 on 6/4/2024 in #🙋questions
Can't find variable: process
I am lately getting ReferenceError: Can't find variable: process which is caused by /server/config.ts and points to:
all: {
env,
isDevelopment: env === 'development',
port: parseInt(process.env.PORT) || 3001,
databaseUrl: process.env.DATABASE_URL,
allowedCORSOrigins: [],
auth: {
jwtSecret: undefined
}
},
all: {
env,
isDevelopment: env === 'development',
port: parseInt(process.env.PORT) || 3001,
databaseUrl: process.env.DATABASE_URL,
allowedCORSOrigins: [],
auth: {
jwtSecret: undefined
}
},
As far as I know, this should be only run in the server and not the client and therefore causing the error. I have not changed anything within the Wasp Project. No matter what I do, once I run wasp start the project only shows a blank page with that error in the web console. Any idea what could happen? OS: MacOS Node version: 18.20.3 Wasp version: 0.13.2
4 replies