Last active
August 19, 2019 11:39
-
-
Save LazyFatArrow/c62805422bb4f5ccebaba9da06b065b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller, Get, Res, Next, Req } from '@nestjs/common'; | |
import { join } from 'path'; | |
import { Response, NextFunction, Request } from 'express'; | |
@Controller() | |
export class AppController { | |
@Get('*') | |
get( | |
@Res() res: Response, | |
@Next() next: NextFunction, | |
@Req() req: Request, | |
) { | |
// here you can check if the requested path is your api endpoint, if that's the case then we have to return next() | |
if (req.path.includes('graphql')) { | |
return next(); | |
} | |
// change the path to the correct html page path in your project | |
res.sendFile(join(process.cwd(), '../client/dist/index.html')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment