Skip to content

Commit 35a4591

Browse files
author
Rajat Saxena
committed
hostname override for courselit
1 parent 74ed8e1 commit 35a4591

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

apps/api/src/config/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ export const CDN_MAX_AGE = process.env.CDN_MAX_AGE
6161
: 1000 * 60 * 60; // one hour
6262

6363
export const ENDPOINT = USE_CLOUDFRONT ? CLOUDFRONT_ENDPOINT : S3_ENDPOINT;
64+
export const HOSTNAME_OVERRIDE = process.env.HOSTNAME_OVERRIDE || ""; // Useful for hosting via Docker

apps/api/src/presigning/handlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Request } from "express";
22
import Joi from "joi";
33
import logger from "../services/log";
44
import * as preSignedUrlService from "./service";
5+
import { HOSTNAME_OVERRIDE } from "../config/constants";
56

67
function validatePresigningOptions(req: Request): Joi.ValidationResult {
78
const uploadSchema = Joi.object({
@@ -26,7 +27,7 @@ export async function getPresignedUrl(
2627
userId: req.user.id,
2728
apikey: req.apikey,
2829
protocol: req.protocol,
29-
host: req.get("Host"),
30+
host: HOSTNAME_OVERRIDE || req.get("Host"),
3031
group: req.body.group,
3132
});
3233
return res.status(200).json({ message: presignedUrl });

0 commit comments

Comments
 (0)