Skip to content

Commit

Permalink
feat(sandbox): use https as default protocol for sandboxing
Browse files Browse the repository at this point in the history
The sandboxing protocol setting is used to determine where to redirect
users when sandboxing is enabled. Previously it defaulted to http or
https based on whether req.secure was true. In the default setup using
Envoy, that's never true because Envoy to service communication goes over
http. It could still be overriden using SANDBOX_PROTOCOL environment
variable, but most users haven't done that. This change switches the
default to https since most people deploy using https. Overrides for
http can still be accomplished using the environment variable.

Resolves #56
  • Loading branch information
djwhitt committed Oct 13, 2023
1 parent ee03255 commit 38eb496
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/middleware/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function createSandboxMiddleware({
if (reqSandbox !== idSandbox) {
const queryString = url.parse(req.originalUrl).query ?? '';
const path = req.path.replace(/\/\//, '/');
const protocol = sandboxProtocol ?? (req.secure ? 'https' : 'http');
const protocol = sandboxProtocol ?? 'https';
return res.redirect(
302,
`${protocol}://${idSandbox}.${config.ARNS_ROOT_HOST}${path}?${queryString}`,
Expand Down

0 comments on commit 38eb496

Please sign in to comment.