mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-05 12:06:36 -05:00
fix(api): control host with env var (#55439)
This commit is contained in:
committed by
GitHub
parent
e8b15a255b
commit
5fcdfe0ec2
@@ -4,7 +4,7 @@
|
||||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
||||
/// <reference path="./reset.d.ts" />
|
||||
import { build } from './app';
|
||||
import { FREECODECAMP_NODE_ENV, PORT } from './utils/env';
|
||||
import { FREECODECAMP_NODE_ENV, HOST, PORT } from './utils/env';
|
||||
|
||||
const envToLogger = {
|
||||
development: {
|
||||
@@ -27,7 +27,7 @@ const start = async () => {
|
||||
try {
|
||||
const port = Number(PORT);
|
||||
fastify.log.info(`Starting server on port ${port}`);
|
||||
await fastify.listen({ port });
|
||||
await fastify.listen({ port, host: HOST });
|
||||
} catch (err) {
|
||||
fastify.log.error(err);
|
||||
process.exit(1);
|
||||
|
||||
@@ -68,6 +68,7 @@ if (process.env.FREECODECAMP_NODE_ENV !== 'development') {
|
||||
assert.ok(process.env.COOKIE_DOMAIN);
|
||||
assert.notEqual(process.env.COOKIE_SECRET, 'a_cookie_secret');
|
||||
assert.ok(process.env.PORT);
|
||||
assert.ok(process.env.HOST);
|
||||
assert.ok(process.env.SENTRY_DSN);
|
||||
// The following values can exist in development, but production-like
|
||||
// environments need to override the defaults.
|
||||
@@ -111,6 +112,7 @@ export const FREECODECAMP_NODE_ENV = process.env.FREECODECAMP_NODE_ENV;
|
||||
export const AUTH0_DOMAIN = process.env.AUTH0_DOMAIN;
|
||||
export const AUTH0_AUDIENCE = process.env.AUTH0_AUDIENCE;
|
||||
export const PORT = process.env.PORT || '3000';
|
||||
export const HOST = process.env.HOST || 'localhost';
|
||||
export const API_LOCATION = process.env.API_LOCATION;
|
||||
export const FCC_ENABLE_SWAGGER_UI =
|
||||
process.env.FCC_ENABLE_SWAGGER_UI === 'true';
|
||||
|
||||
Reference in New Issue
Block a user