mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
4 changed files with 26 additions and 5 deletions
@ -0,0 +1,7 @@
|
||||
import { GlobalMiddleware } from './global.middleware'; |
||||
|
||||
describe('GlobalMiddleware', () => { |
||||
it('should be defined', () => { |
||||
expect(new GlobalMiddleware()).toBeDefined(); |
||||
}); |
||||
}); |
@ -0,0 +1,14 @@
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common'; |
||||
import Noco from '../../Noco'; |
||||
|
||||
@Injectable() |
||||
export class GlobalMiddleware implements NestMiddleware { |
||||
use(req: any, res: any, next: () => void) { |
||||
req.ncSiteUrl = |
||||
Noco.config?.envs?.[Noco.env]?.publicUrl || |
||||
Noco.config?.publicUrl || |
||||
req.protocol + '://' + req.get('host'); |
||||
req.ncFullUrl = req.protocol + '://' + req.get('host') + req.originalUrl; |
||||
next(); |
||||
} |
||||
} |
Loading…
Reference in new issue