moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
291 stars 119 forks source link

fix: add 201 Created to status codes #297

Closed mtiller closed 1 year ago

mtiller commented 2 years ago

The Location header is also used by the 201 Created status code. But the currently logic filters out the information provided in ctx.meta.$location if I return ctx.meta.$statusCode = 201. This should not happen. The Location header is essential in a 201 Created response. I've changed to logic so that 201 is included in the status codes that passthrough ctx.meta.$location to the Location header.

icebob commented 1 year ago

@mtiller sorry for being late but I don't get emails about new commits, just comments.

thib3113 commented 8 months ago

Hello @mtiller / @icebob .

Some questions about this change .

Actually, the spec doesn't restrict the use of the Location header . So every status code can use it .

Also, about the 201 code, the specification says :

The primary resource created by the request is identified by either a Location header field in the response or, if no Location header field is received, by the target URI

so the warning on https://github.com/moleculerjs/moleculer-web/pull/297/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R707 is not relevant in this case (nor in others because of the specification, but I can understand that can be interesting for some peoples)

icebob commented 7 months ago

@thib3113 nice catch, could you create a PR with ignoring the warning in case of 201?