Skip to content

Commit

Permalink
Correctly set secure flag by trusting CF proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
illegalprime committed Oct 13, 2017
1 parent 252ad5a commit 1321839
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ secrets:
- DEFAULT_ADMIN_PASS

env:
PRODUCTION: true
REGISTRATION_GRAPHQL: "https://registration.dev.hack.gt/graphql"

wants:
Expand Down
4 changes: 4 additions & 0 deletions server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const VERSION_HASH = require("git-rev-sync").short();

export let app = express();

if (config.server.production) {
app.enable("trust proxy");
}

app.use(compression());
let cookieParserInstance = cookieParser(undefined, {
"path": "/",
Expand Down
4 changes: 3 additions & 1 deletion server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface IConfig {
server: {
port: number;
mongo: string;
production: boolean;
},
inputs: {
registration: string;
Expand All @@ -20,7 +21,8 @@ export interface IConfig {
export const config: IConfig = {
server: {
port: envOrDefaultMap("PORT", 3000, parseInt),
mongo: envOrDefault("MONGO_URL", "mongodb://localhost/checkin")
mongo: envOrDefault("MONGO_URL", "mongodb://localhost/checkin"),
production: envOrDefault("PRODUCTION", "false").toLowerCase() === "true",
},
inputs: {
registration: envOrDefault("REGISTRATION_GRAPHQL", "https://registration.dev.hack.gt/graphql")
Expand Down
2 changes: 1 addition & 1 deletion server/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export function setupRoutes(app: express.Express, registration: Registration) {
(request, response, next) => {
graphiqlExpress({
endpointURL: "/graphql",
subscriptionsEndpoint: createLink(request, "graphql", "wss")
subscriptionsEndpoint: createLink(request, "graphql", "ws")
})(request, response, next);
}
);
Expand Down

0 comments on commit 1321839

Please sign in to comment.