Skip to content

Commit

Permalink
fix: 修复 nextAuth 回调地址设置错误
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyao27 committed Sep 8, 2022
1 parent da926ac commit 0b4935d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:

nginx:
image: nginx:alpine
restart: always
ports:
- '3001:3001'
- '6661:6661'
Expand Down
6 changes: 1 addition & 5 deletions ohbug.config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
http:
url: 127.0.0.1

# https:
# key: ./secrets/key.pem
# cert: ./secrets/cert.pem
url: http://localhost:3000

db:
postgres:
Expand Down
4 changes: 0 additions & 4 deletions packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export interface Config {
http: {
url: string
}
https?: {
key: string
cert: string
}
db: {
postgres: {
host: string
Expand Down
9 changes: 4 additions & 5 deletions scripts/createEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@ import type { Config } from '../packages/config'
const YAML_CONFIG_FILENAME = 'ohbug.config.yml'
const DEVELOP_YAML_CONFIG_FILENAME = 'ohbug.config.development.yml'
const FILE_NAME = '.env'
const WEB_PORT = 3000

async function main() {
const rootFilePath = join(cwd(), FILE_NAME)
const webFilePath = join(cwd(), 'packages/web', FILE_NAME)
const configPath = join(cwd(), process.env.NODE_ENV === 'development' ? DEVELOP_YAML_CONFIG_FILENAME : YAML_CONFIG_FILENAME)
const config = yaml.load(await readFile(configPath, 'utf8')) as Config
const httpPrefix = config.https ? 'https' : 'http'
const port = config.https ? 3001 : 3000
const fileContents = `NEXT_PUBLIC_VERSION=${pkg.version}
DB_USER=${config.db.postgres.user}
DB_PASSWORD=${config.db.postgres.password}
DB_NAME=${config.db.postgres.database}
DATABASE_URL="postgresql://${config.db.postgres.user}:${config.db.postgres.password}@${config.db.postgres.host}:${config.db.postgres.port}/${config.db.postgres.database}"
NEXTAUTH_URL=${httpPrefix}://${config.http.url}:${port}
NEXTAUTH_URL_INTERNAL=http://localhost:3000
NEXTAUTH_URL=${config.http.url}
NEXTAUTH_URL_INTERNAL=http://localhost:${WEB_PORT}
NEXTAUTH_SECRET=${config.secret?.session ?? 'ohbug-session-s3cret'}
NEXT_PUBLIC_NEXTAUTH_URL=${httpPrefix}://${config.http.url}:${port}
NEXT_PUBLIC_NEXTAUTH_URL=${config.http.url}
`
await writeFile(rootFilePath, fileContents)
await writeFile(webFilePath, fileContents)
Expand Down

0 comments on commit 0b4935d

Please sign in to comment.