Routing-controllers: Koa @Render makes all the other routes fail

Created on 8 Mar 2018  路  8Comments  路  Source: typestack/routing-controllers

After I add @Render(page) to a particular route, all the other routes (even in the different controllers) render that page as well.

awaiting answer fix

All 8 comments

Is there any reason you cannot use Express? There is no difference between to two nowadays with ES6 around. None of us (contributors) is really familiar with Koa, so feel free to propose a fix if you cannot switch to express.

Also, Koa support will be eventually removed in favor of full abstraction, so we can swap the underlying engine.

@AegoYu I am getting this issue too when the server starts I can get a route that should return JSON and it works. When I load a route that renders a template, I correctly see the rendered HTML. However, when I then go back to a route that will return JSON it shows part of the rendered HTML.

If you flush the headers before other responses does it fix the issue for you?

same

https://github.com/typestack/routing-controllers/blob/master/src/driver/koa/KoaDriver.ts#L235

the value action.renderedTemplate was putted into a js closure. once the middleware initialized, the view will never changed.

Hello when this issue will be finished
As this is causing Major Bugs

For Koa-specific things like this, the best bet is to use a typescript routing controller made specifically for Koa, like https://github.com/iyobo/koa-ts-controllers.

This particular repo routing-controllers is more for express. Koa is and will always be an after-thought and when clashes like this happen, express will take priority.

Stale issue message

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GBeushausen picture GBeushausen  路  5Comments

iangregsondev picture iangregsondev  路  3Comments

ghost picture ghost  路  5Comments

davidquintard picture davidquintard  路  4Comments

codedoge picture codedoge  路  6Comments