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 parent
a62a8be016
commit
fa0c7dfbb5
3 files changed
+15
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
import { EOL } from "os"
|
import { EOL } from "os"
|
||||||
import pg from "pg"
|
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 inquirer from "inquirer"
|
||||||
import logMessage from "./log-message.js"
|
import logMessage from "./log-message.js"
|
||||||
import formatConnectionString from "./format-connection-string.js"
|
import formatConnectionString from "./format-connection-string.js"
|
||||||
@@ -66,10 +66,16 @@ async function getForDbName({
|
|||||||
let postgresUsername = "postgres"
|
let postgresUsername = "postgres"
|
||||||
let postgresPassword = ""
|
let postgresPassword = ""
|
||||||
|
|
||||||
|
const defaultConnectionOptions = {
|
||||||
|
host: DEFAULT_HOST,
|
||||||
|
port: DEFAULT_PORT
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client = await postgresClient({
|
client = await postgresClient({
|
||||||
user: postgresUsername,
|
user: postgresUsername,
|
||||||
password: postgresPassword,
|
password: postgresPassword,
|
||||||
|
...defaultConnectionOptions
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
@@ -103,6 +109,7 @@ async function getForDbName({
|
|||||||
client = await postgresClient({
|
client = await postgresClient({
|
||||||
user: postgresUsername,
|
user: postgresUsername,
|
||||||
password: postgresPassword,
|
password: postgresPassword,
|
||||||
|
...defaultConnectionOptions
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logMessage({
|
logMessage({
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import pg from "pg"
|
import pg from "pg"
|
||||||
const { Client } = pg
|
const { Client } = pg
|
||||||
|
|
||||||
|
export const DEFAULT_HOST = "localhost"
|
||||||
|
export const DEFAULT_PORT = 5432
|
||||||
|
|
||||||
type PostgresConnection = {
|
type PostgresConnection = {
|
||||||
user?: string
|
user?: string
|
||||||
password?: string
|
password?: string
|
||||||
connectionString?: string
|
connectionString?: string
|
||||||
database?: string
|
database?: string
|
||||||
|
host?: string
|
||||||
|
port?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (connect: PostgresConnection) => {
|
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
|
// 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 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 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"
|
const DEFAULT_REDIS_URL = "redis://localhost:6379"
|
||||||
|
|
||||||
type PrepareOptions = {
|
type PrepareOptions = {
|
||||||
@@ -72,7 +73,7 @@ export default async ({
|
|||||||
let inviteToken: string | undefined = undefined
|
let inviteToken: string | undefined = undefined
|
||||||
|
|
||||||
// add environment variables
|
// 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) {
|
if (!skipDb) {
|
||||||
env += `${EOL}DATABASE_URL=${dbConnectionString}${EOL}POSTGRES_URL=${dbConnectionString}`
|
env += `${EOL}DATABASE_URL=${dbConnectionString}${EOL}POSTGRES_URL=${dbConnectionString}`
|
||||||
|
|||||||
Reference in new issue
Block a user