mirror of https://github.com/nocodb/nocodb
աɨռɢӄաօռɢ
1 year ago
committed by
GitHub
20 changed files with 5 additions and 40 deletions
@ -1,7 +0,0 @@ |
|||||||
import { PublicMiddleware } from './public.middleware'; |
|
||||||
|
|
||||||
describe('PublicMiddleware', () => { |
|
||||||
it('should be defined', () => { |
|
||||||
expect(new PublicMiddleware()).toBeDefined(); |
|
||||||
}); |
|
||||||
}); |
|
@ -1,23 +0,0 @@ |
|||||||
import path, { join } from 'path'; |
|
||||||
import { Injectable } from '@nestjs/common'; |
|
||||||
import express from 'express'; |
|
||||||
import isDocker from 'is-docker'; |
|
||||||
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
|
|
||||||
if (isDocker()) { |
|
||||||
express.static(join(process.cwd(), 'docker', 'public'))(req, res, next); |
|
||||||
} else { |
|
||||||
express.static(join(process.cwd(), 'public'))(req, res, next); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Loading…
Reference in new issue