Skip to content

Commit

Permalink
fix: missing Location in headers when statu code 201
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Jan 17, 2022
1 parent 9c5e860 commit 8092545
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/FHIRApiService/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module.exports = async function(req, res , resourceType) {
try {
let resFunc = {
"true": (doc) => {
let reqBaseUrl = `${req.protocol}://${req.get('host')}/`;
let fullAbsoluteUrl = new URL(req.originalUrl, reqBaseUrl).href;
res.set("Location", fullAbsoluteUrl);
return doRes(201 , doc);
},
"false": (err) => {
Expand Down
5 changes: 5 additions & 0 deletions api/FHIRApiService/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ module.exports = async function (req, res, resourceType) {
}
let resFunc = {
"true": (data) => {
if (data.code == 201) {
let reqBaseUrl = `${req.protocol}://${req.get('host')}/`;
let fullAbsoluteUrl = new URL(req.originalUrl, reqBaseUrl).href;
res.set("Location", fullAbsoluteUrl);
}
return doRes(data.code, data.doc);
},
"false": (err) => {
Expand Down

0 comments on commit 8092545

Please sign in to comment.