fix(create-medusa-app): set the database host and port explicitely (#7637)
* pass host and port explicitely * set AUTH_CORS in env
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { EOL } from "os"
|
||||
import pg from "pg"
|
||||
import postgresClient from "./postgres-client.js"
|
||||
import postgresClient, { DEFAULT_HOST, DEFAULT_PORT } from "./postgres-client.js"
|
||||
import inquirer from "inquirer"
|
||||
import logMessage from "./log-message.js"
|
||||
import formatConnectionString from "./format-connection-string.js"
|
||||
@@ -66,10 +66,16 @@ async function getForDbName({
|
||||
let postgresUsername = "postgres"
|
||||
let postgresPassword = ""
|
||||
|
||||
const defaultConnectionOptions = {
|
||||
host: DEFAULT_HOST,
|
||||
port: DEFAULT_PORT
|
||||
}
|
||||
|
||||
try {
|
||||
client = await postgresClient({
|
||||
user: postgresUsername,
|
||||
password: postgresPassword,
|
||||
...defaultConnectionOptions
|
||||
})
|
||||
} catch (e) {
|
||||
if (verbose) {
|
||||
@@ -103,6 +109,7 @@ async function getForDbName({
|
||||
client = await postgresClient({
|
||||
user: postgresUsername,
|
||||
password: postgresPassword,
|
||||
...defaultConnectionOptions
|
||||
})
|
||||
} catch (e) {
|
||||
logMessage({
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import pg from "pg"
|
||||
const { Client } = pg
|
||||
|
||||
export const DEFAULT_HOST = "localhost"
|
||||
export const DEFAULT_PORT = 5432
|
||||
|
||||
type PostgresConnection = {
|
||||
user?: string
|
||||
password?: string
|
||||
connectionString?: string
|
||||
database?: string
|
||||
host?: string
|
||||
port?: number
|
||||
}
|
||||
|
||||
export default async (connect: PostgresConnection) => {
|
||||
|
||||
@@ -12,6 +12,7 @@ const ADMIN_EMAIL = "admin@medusa-test.com"
|
||||
// TODO remove preview links once we move to main docs
|
||||
const STORE_CORS = "http://localhost:8000,https://docs.medusajs.com,https://medusa-docs-v2-git-docs-v2-medusajs.vercel.app,https://medusa-resources-git-docs-v2-medusajs.vercel.app"
|
||||
const ADMIN_CORS = "http://localhost:7000,http://localhost:7001,https://docs.medusajs.com,https://medusa-docs-v2-git-docs-v2-medusajs.vercel.app,https://medusa-resources-git-docs-v2-medusajs.vercel.app"
|
||||
const AUTH_CORS = ADMIN_CORS
|
||||
const DEFAULT_REDIS_URL = "redis://localhost:6379"
|
||||
|
||||
type PrepareOptions = {
|
||||
@@ -72,7 +73,7 @@ export default async ({
|
||||
let inviteToken: string | undefined = undefined
|
||||
|
||||
// add environment variables
|
||||
let env = `MEDUSA_ADMIN_ONBOARDING_TYPE=${onboardingType}${EOL}STORE_CORS=${STORE_CORS}${EOL}ADMIN_CORS=${ADMIN_CORS}${EOL}REDIS_URL=${DEFAULT_REDIS_URL}${EOL}JWT_SECRET=supersecret${EOL}COOKIE_SECRET=supersecret`
|
||||
let env = `MEDUSA_ADMIN_ONBOARDING_TYPE=${onboardingType}${EOL}STORE_CORS=${STORE_CORS}${EOL}ADMIN_CORS=${ADMIN_CORS}${EOL}AUTH_CORS=${AUTH_CORS}${EOL}REDIS_URL=${DEFAULT_REDIS_URL}${EOL}JWT_SECRET=supersecret${EOL}COOKIE_SECRET=supersecret`
|
||||
|
||||
if (!skipDb) {
|
||||
env += `${EOL}DATABASE_URL=${dbConnectionString}${EOL}POSTGRES_URL=${dbConnectionString}`
|
||||
|
||||
Reference in New Issue
Block a user