Browse Source

fix: Handling publicUrl

re #370

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/401/head
Pranav C 3 years ago
parent
commit
651aee8124
  1. 1
      packages/nocodb/src/interface/config.ts
  2. 3
      packages/nocodb/src/lib/noco/Noco.ts
  3. 5
      packages/nocodb/src/lib/utils/NcConfigFactory.ts

1
packages/nocodb/src/interface/config.ts

@ -218,6 +218,7 @@ export interface NcConfig {
dashboardPath?: string;
prefix?: string;
publicUrl?: string;
}

3
packages/nocodb/src/lib/noco/Noco.ts

@ -177,13 +177,14 @@ export default class Noco {
/******************* Middlewares : start *******************/
this.router.use((req: any, _res, next) => {
req.nc = this.requestContext;
req.ncSiteUrl = this.config?.envs?.[this.env]?.publicUrl || (req.protocol + '://' + req.get('host'));
req.ncSiteUrl = this.config?.envs?.[this.env]?.publicUrl || this.config?.publicUrl || (req.protocol + '://' + req.get('host'));
req.ncFullUrl = req.protocol + '://' + req.get('host') + req.originalUrl;
next();
});
// to get ip addresses
this.router.use(requestIp.mw())
this.router.use(cookieParser());
this.router.use(bodyParser.json({

5
packages/nocodb/src/lib/utils/NcConfigFactory.ts

@ -73,6 +73,7 @@ export default class NcConfigFactory implements NcConfig {
if (process.env.NC_PUBLIC_URL) {
config.envs[process.env.NODE_ENV || 'dev'].publicUrl = process.env.NC_PUBLIC_URL;
config.publicUrl = process.env.NC_PUBLIC_URL;
}
@ -156,6 +157,7 @@ export default class NcConfigFactory implements NcConfig {
if (process.env.NC_PUBLIC_URL) {
config.envs[process.env.NODE_ENV || 'dev'].publicUrl = process.env.NC_PUBLIC_URL;
config.publicUrl = process.env.NC_PUBLIC_URL;
}
@ -382,6 +384,7 @@ export default class NcConfigFactory implements NcConfig {
if (process.env.NC_PUBLIC_URL) {
config.envs[process.env.NODE_ENV || 'dev'].publicUrl = process.env.NC_PUBLIC_URL;
config.publicUrl = process.env.NC_PUBLIC_URL;
}
@ -491,6 +494,7 @@ export default class NcConfigFactory implements NcConfig {
if (process.env.NC_PUBLIC_URL) {
config.envs[process.env.NODE_ENV || 'dev'].publicUrl = process.env.NC_PUBLIC_URL;
config.publicUrl = process.env.NC_PUBLIC_URL;
}
@ -539,6 +543,7 @@ export default class NcConfigFactory implements NcConfig {
public queriesFolder: string | string[] = '';
public seedsFolder: string | string[];
public title: string;
public publicUrl: string;
public projectType;
public meta = {
"db": {

Loading…
Cancel
Save