Add allow-http flag
This commit is contained in:
parent
d739be18a9
commit
e2ec010a1d
|
@ -25,6 +25,7 @@ export class Entry extends Command {
|
||||||
port: flags.integer({ char: "p", default: 8443, description: "Port to bind on" }),
|
port: flags.integer({ char: "p", default: 8443, description: "Port to bind on" }),
|
||||||
version: flags.version({ char: "v" }),
|
version: flags.version({ char: "v" }),
|
||||||
"no-auth": flags.boolean({ default: false }),
|
"no-auth": flags.boolean({ default: false }),
|
||||||
|
"allow-http": flags.boolean({ default: false }),
|
||||||
|
|
||||||
// Dev flags
|
// Dev flags
|
||||||
"bootstrap-fork": flags.string({ hidden: true }),
|
"bootstrap-fork": flags.string({ hidden: true }),
|
||||||
|
@ -134,6 +135,7 @@ export class Entry extends Command {
|
||||||
const password = "023450wf0951";
|
const password = "023450wf0951";
|
||||||
const hasCustomHttps = certData && certKeyData;
|
const hasCustomHttps = certData && certKeyData;
|
||||||
const app = await createApp({
|
const app = await createApp({
|
||||||
|
allowHttp: flags["allow-http"],
|
||||||
bypassAuth: flags["no-auth"],
|
bypassAuth: flags["no-auth"],
|
||||||
registerMiddleware: (app): void => {
|
registerMiddleware: (app): void => {
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
|
|
|
@ -26,6 +26,7 @@ interface CreateAppOptions {
|
||||||
serverOptions?: ServerOptions;
|
serverOptions?: ServerOptions;
|
||||||
password?: string;
|
password?: string;
|
||||||
httpsOptions?: https.ServerOptions;
|
httpsOptions?: https.ServerOptions;
|
||||||
|
allowHttp?: boolean;
|
||||||
bypassAuth?: boolean;
|
bypassAuth?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +188,7 @@ export const createApp = async (options: CreateAppOptions): Promise<{
|
||||||
const authStaticFunc = expressStaticGzip(path.join(baseDir, "build/web/auth"));
|
const authStaticFunc = expressStaticGzip(path.join(baseDir, "build/web/auth"));
|
||||||
const unauthStaticFunc = expressStaticGzip(path.join(baseDir, "build/web/unauth"));
|
const unauthStaticFunc = expressStaticGzip(path.join(baseDir, "build/web/unauth"));
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
if (!isEncrypted(req.socket)) {
|
if (!isEncrypted(req.socket) && !options.allowHttp) {
|
||||||
return res.redirect(301, `https://${req.headers.host!}${req.path}`);
|
return res.redirect(301, `https://${req.headers.host!}${req.path}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue