From 738d3a71aa3c2bc38ac38fe97beb8d3c9be42c13 Mon Sep 17 00:00:00 2001 From: Pranav C <61551451+pranavxc@users.noreply.github.com> Date: Tue, 29 Jun 2021 18:06:20 +0530 Subject: [PATCH] fix: add both schemes in swagger fix #311 Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com> --- packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts b/packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts index a51fab5810..49081350eb 100644 --- a/packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts +++ b/packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts @@ -1510,11 +1510,11 @@ export class RestApiBuilder extends BaseApiBuilder { if (this.config?.auth?.jwt?.dbAlias !== this.connectionConfig.meta.dbAlias) { swaggerBaseDocument = {...swaggerBaseDocument, tags: [], definitions: {}, paths: {}}; } - + const host = process.env.NC_PUBLIC_URL ? new URL(process.env.NC_PUBLIC_URL)?.host : req.get('host'); const scheme = process.env.NC_PUBLIC_URL ? new URL(process.env.NC_PUBLIC_URL)?.protocol.slice(0, -1) : req.protocol; swaggerBaseDocument.host = host; - swaggerBaseDocument.schemes = [scheme]; + swaggerBaseDocument.schemes = [scheme, scheme === 'http' ? 'https' : 'http']; glob.sync(path.join(this.config.toolDir, 'nc', this.projectId, this.getDbAlias(), 'swagger', 'swagger.json')).forEach(jsonFile => { const swaggerJson = JSON.parse(fs.readFileSync(jsonFile, 'utf8')); swaggerBaseDocument.tags.push(...swaggerJson.tags);