mirror of https://github.com/ghostfolio/ghostfolio
committed by
GitHub
6 changed files with 44 additions and 19 deletions
@ -0,0 +1,33 @@ |
|||
import * as path from 'path'; |
|||
|
|||
import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; |
|||
import { Injectable, NestMiddleware } from '@nestjs/common'; |
|||
import { NextFunction, Request, Response } from 'express'; |
|||
|
|||
@Injectable() |
|||
export class FrontendMiddleware implements NestMiddleware { |
|||
use(req: Request, res: Response, next: NextFunction) { |
|||
if (req.path.startsWith('/api/') || this.isFileRequest(req.url)) { |
|||
// Skip
|
|||
next(); |
|||
} else { |
|||
res.sendFile( |
|||
path.join( |
|||
__dirname, |
|||
'..', |
|||
'client', |
|||
DEFAULT_LANGUAGE_CODE, |
|||
'index.html' |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
private isFileRequest(filename: string) { |
|||
if (filename.includes('auth/ey')) { |
|||
return false; |
|||
} |
|||
|
|||
return filename.split('.').pop() !== filename; |
|||
} |
|||
} |
@ -1,10 +0,0 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<title>Ghostfol.io</title> |
|||
<link rel="canonical" href="https://ghostfol.io/en/" /> |
|||
<meta name="robots" content="noindex" /> |
|||
<meta charset="utf-8" /> |
|||
<meta http-equiv="refresh" content="0; url=./en/" /> |
|||
</head> |
|||
</html> |
Loading…
Reference in new issue