mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
3 changed files with 28 additions and 6 deletions
@ -0,0 +1,7 @@
|
||||
import { PublicMiddleware } from './public.middleware'; |
||||
|
||||
describe('PublicMiddleware', () => { |
||||
it('should be defined', () => { |
||||
expect(new PublicMiddleware()).toBeDefined(); |
||||
}); |
||||
}); |
@ -0,0 +1,18 @@
|
||||
import { join } from 'path'; |
||||
import { Injectable } from '@nestjs/common'; |
||||
import express from 'express'; |
||||
import type { NestMiddleware } from '@nestjs/common'; |
||||
|
||||
@Injectable() |
||||
export class PublicMiddleware implements NestMiddleware { |
||||
use(req: any, res: any, next: () => void) { |
||||
// redirect root to dashboard
|
||||
if (req.path === '/') { |
||||
const dashboardPath = process.env.NC_DASHBOARD_URL || '/dashboard'; |
||||
return res.redirect(dashboardPath); |
||||
} |
||||
|
||||
// serve static files from public folder
|
||||
express.static(join(process.cwd(), 'public'))(req, res, next); |
||||
} |
||||
} |
Loading…
Reference in new issue