여기 내 경로 정의는 Express.js에 : 나는를 사용하려고하면Express.js의 특정 경로에서 일반 경로가 헤더를 설정하지 못하게하려면 어떻게해야합니까?
// Building specific routes defined by a route file
routes.use(this.initialize.bind(this));
routes.use(this.isAuthenticated.bind(this));
routes.use(this.isAuthorized.bind(this));
if (Route.METHOD == 'POST') {
routes.use(route.post.bind(route));
} else {
routes.use(route.get.bind(route));
}
routes.use(this.finalize.bind(this));
router.use('/webstore/' + Route.RESOURCE + (parameters.length != 0 ? '/' : '') + parameters.join('/'), routes);
//router.use('/webstore/session', routes);
// Building generic routes
console.log('Creating GET route: ' +
'/:connectionName(webstore|localdatastore)/:objectName');
router.get('/:connectionName(webstore|localdatastore)/:objectName',
this.initialize.bind(this), this.isAuthenticated.bind(this), this.isAuthorized.bind(this), this.get.bind(this), this.finalize.bind(this));
console.log('Creating POST route: ' +
'/:connectionName(webstore|localdatastore)/:objectName');
router.post('/:connectionName(webstore|localdatastore)/:objectName',
this.initialize.bind(this), this.isAuthenticated.bind(this), this.isAuthorized.bind(this), this.get.bind(this), this.finalize.bind(this));
I는 위의 두 줄에 정의 된 /webstore/user
로, 일반적인 경로를 액세스하려고하면, 내 코드는하지만, 잘 작동
Error: Can't set headers after they are sent.
at ServerResponse.setHeader (_http_outgoing.js:371:11)
at ServerResponse.header (./node_modules/express/lib/response.js:767:10)
at ServerResponse.contentType (./node_modules/express/lib/response.js:595:15)
at Server.finalize (./dist/server.js:1156:17)
at Layer.handle [as handle_request] (./node_modules/express/lib/router/layer.js:95:5)
...
내 API는 횡보,이 오류를 제거 할 때의 별명을 추가 할 필요가 없습니다 싶습니다 : 경로 파일에서 위에서 정의 된 특정 경로 등 /webstore/session
, 나는이 오류가 발생합니다. 일반 경로와 정의 된 경로가 충돌하여 Express가 헤더를 설정하지 못하도록하려면 어떻게해야합니까?
죄송합니다. 당신은 올바른 길로 나를 잡았고, 곧이 문제를 해결했지만, 새해 이후에 업데이트하는 것을 잊어 버렸을 것입니다. – NobleUplift