-
Notifications
You must be signed in to change notification settings - Fork 26
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
Header Location ist not set propertly #222
Comments
You seem to be using a For your use case, you can modify your mock file as follows: HTTP/1.1 201 CREATED
Access-Control-Allow-Origin: *
{{#code}}
(()=>{
return {
status:201,
headers: {
'Content-Type': 'text/html',
'Location': `/api/file/download/${request.query.userId}`
}
};
})();
{{/code}} |
@shubhendumadhukar thank you very much for your example, I just tried it. Unfortunately, I have the same problem, in Browser DevTools I can see the 'location' to set correctly, but in the app code, it still not there: To fetch data I am using axios. The code looks like: this.file
.download()
.then((response) => {
console.log(response.headers)
}); The location property seems NOT to work locally (when using the Mock server), in DEV/STAGE/PROD there are no issues with the code above. |
I am unfortunately unable to reproduce it. I tried calling the mock using the axios code as follows: const axios = require("axios");
const options = {
method: "GET",
url: "http://localhost:8080/test",
params: { userId: "1212" },
headers: { "user-agent": "vscode-restclient" },
};
axios
.request(options)
.then(function (response) {
console.log(response.headers);
})
.catch(function (error) {
console.error(error);
}); These are the headers I could see in the console. AxiosHeaders {
'x-powered-by': 'Express',
vary: 'Origin, Accept-Encoding',
'access-control-allow-origin': '*',
'content-type': 'text/html; charset=utf-8',
location: '/api/file/download/1212',
date: 'Fri, 28 Jul 2023 05:33:15 GMT',
connection: 'close',
'transfer-encoding': 'chunked'
} Would you be able to share the complete set of response headers you receive when you call the actual API instead of the mock? If yes, please ensure that sensitive data, if any, are masked from the response before sharing. |
Describe the bug
When I set a "location" property in response headers, then it is shown in Browser Chrome DevTools -> Network/Headers, but when I try to get
response.headers.location
in Code or just console.logrepsonse.headers
it returns onlycontent.type
andcontent-lenght
propertyTo Reproduce
Here is my code to reproduce. I have tried to only set Location directly in after HTTP and in {{#code}} block. Both return the same result.
Expected behavior
When calling
response.headers.location
it should NOT be undefinedDesktop:
The text was updated successfully, but these errors were encountered: