Closed hans642 closed 1 week ago
You can try to modify the databaseDriverOptions in the medusa-config.js file:
module.exports = defineConfig({
projectConfig: {
databaseDriverOptions: { ssl: { rejectUnauthorized: true } },
// ......
},
Please check the medusa-config.ts file
import { loadEnv, defineConfig } from '@medusajs/framework/utils'
loadEnv(process.env.NODE_ENV || 'development', process.cwd())
module.exports = defineConfig({
projectConfig: {
databaseDriverOptions: { ssl: { rejectUnauthorized: true } },
databaseUrl: process.env.DATABASE_URL,
http: {
storeCors: process.env.STORE_CORS!,
adminCors: process.env.ADMIN_CORS!,
authCors: process.env.AUTH_CORS!,
jwtSecret: process.env.JWT_SECRET || "supersecret",
cookieSecret: process.env.COOKIE_SECRET || "supersecret",
}
}
})
also got
✗ npx medusa db:create --verbose
? Enter the database name shop_v2
error: Unable to establish database connection because of the following error
error: connection is insecure (try using `sslmode=require`)
error: connection is insecure (try using `sslmode=require`)
I do not why but medusa 2.0 accepts the following value to disable ssl check. hope team looks into this.
postgres://.....................?ssl_mode=disable
add
?ssl_mode=disable
Hello @hans642
Thanks for reporting the issue. I can confirm that it is a bug. We are working on a fix
Meanwhile @hans642 Can you please create the database manually and confirm if you are able to run the npx medusa db:mgirate
command or not?
First create database manually then run migrate command. This is run error:
(v2) ✗ npx medusa db:migrate
redisUrl not found. A fake redis instance will be used.
info: Running migrations...
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
info: MODULE: cache
error: Failed with error connection is insecure (try using `sslmode=require`)
error: connection is insecure (try using `sslmode=require`)
error: connection is insecure (try using `sslmode=require`)
Thanks for verifying that. Can you please share your medusa-config.ts
file?
import { loadEnv, defineConfig } from '@medusajs/framework/utils'
loadEnv(process.env.NODE_ENV || 'development', process.cwd())
module.exports = defineConfig({
projectConfig: {
databaseDriverOptions: { ssl: { rejectUnauthorized: false } },
databaseUrl: process.env.DATABASE_URL,
http: {
storeCors: process.env.STORE_CORS!,
adminCors: process.env.ADMIN_CORS!,
authCors: process.env.AUTH_CORS!,
jwtSecret: process.env.JWT_SECRET || "supersecret",
cookieSecret: process.env.COOKIE_SECRET || "supersecret",
}
}
})
I've used to have a similar issue to this one, and I fixed it by doing the following,
?ssl_mode=disable
to the end of my DATABASE_URL
+POSTGRES_URL
connection string.medusa-config.js
module.exports = defineConfig({
projectConfig: {
[...]
databaseDriverOptions: {
ssl: false,
},
[...]
}
[...]
}
POSTGRES_DRIVER_OPTIONS={ "connection": { "ssl": false } }
and DB_DRIVER_OPTIONS={ "connection": { "ssl": false } }
. This is working for me.
I actually expect the db:migrate
command to work without making any sort of modifications in the medusa-config.ts
file.
Because I am able to run migrations targeting a Neon DB with the following medusa config file and env variables.
import { loadEnv, defineConfig } from '@medusajs/framework/utils'
loadEnv(process.env.NODE_ENV || 'development', process.cwd())
module.exports = defineConfig({
projectConfig: {
databaseUrl: process.env.DATABASE_URL,
http: {
storeCors: process.env.STORE_CORS!,
adminCors: process.env.ADMIN_CORS!,
authCors: process.env.AUTH_CORS!,
jwtSecret: process.env.JWT_SECRET || "supersecret",
cookieSecret: process.env.COOKIE_SECRET || "supersecret",
}
}
})
DB_NAME=medusa-test
DATABASE_URL=postgresql://medusa-test_owner:*****@*****.us-east-2.aws.neon.tech/medusa-test?sslmode=require
The db:create
command is addressed by this PR. https://github.com/medusajs/medusa/pull/9992
Package.json file
Node.js version
v20.15.1
Database and its version
16.4
Operating system name and version
macOS 15.1
Browser name
No response
What happended?
When create database use Vercel postgress .env config
cmd:
npx medusa db:create
Got error:Then update the .env config
got error:
Expected behavior
Hope can use Vercel postgress config the sslmode
Actual behavior
Can't use it
Link to reproduction repo
medusa(v2)