-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage with next-routes #39
Comments
Can you elaborate on what happens when trying to use `useRouter`?
It sounds like this may be two separate issues, but in general we don’t support other 3rd party routing libraries. nest-next uses nestjs for the routing but you can add a global filter to pass requests that don’t resolve within nest and try to resolve the request with next. See this issue for context #38
…On Feb 2, 2020, 8:37 PM -0600, Webber Wang ***@***.***>, wrote:
Reopened #39.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Right, solving issue 2 (resolving requests not resolved in nest) would solve 1 (external router not working), since we wouldn't need Here's my attempt following #38... server.ts @Catch(NotFoundException)
export class NextPageFilter implements ExceptionFilter {
private requestHandler?: RequestHandler;
constructor(@Inject() private readonly renderService: RenderService) {
this.requestHandler = this.renderService.getRequestHandler();
}
catch(exception: HttpException, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const res = ctx.getResponse();
const req = ctx.getRequest();
if (this.requestHandler) {
return this.requestHandler(req, res);
}
throw exception;
}
}
(async () => {
/**
* Create server
*/
const server = Server({
dev: true,
});
await server.prepare();
/**
* Create app
*/
const app = await NestFactory.create(AppModule);
const renderer = app.get(RenderModule);
renderer.register(app as any, server);
/**
* Add service
*/
const service = app.get(RenderService);
app.useGlobalFilters(new NextPageFilter(service));
await app.listen(3000);
})();
|
@webberwang I added a new option in the nest-next beta preview. I think that it may allow for you to use next-routes. See #38 (comment) |
The controller stops working if I use the routes handler.
I'm also unable to access
useRouter().query
fromnext/router
if I'm using routing with controllerThe text was updated successfully, but these errors were encountered: