how to use cookie from request headers ?
See original GitHub issueHello, I’m trying to use wordpress with wp-graphql and I need to post some mutations from my nuxt front-end. I’m using wp-grapql-cors to login and there is indeed a Set-Cookie in the response headers. Using Postman, I can see the cookie and with authorization tab set to “inherit from parent”, if I post a mutation to create a page for example, it works. But within nuxt, I dont know how to configure “nuxt-grapql-client” in order to have something equivalent ! Any help or example, is welcome ! Thank you. PS: Here is a working generated example code from postman using axios:
var axios = require('axios');
var data = JSON.stringify({
query: `mutation createPost {
createPost(input: {
title: "A nice title"
content: "some content",
status: PUBLISH
}) {
clientMutationId
}
}`,
variables: {}
});
var config = {
method: 'post',
url: 'https://galpon.test/graphql',
headers: {
'Content-Type': 'application/json',
'Cookie': 'wordpress_logged_in_0a80706747350ab2bd151dfb3be09ba4=test2%7C1654774457%7CaUXw73nZkYwr1uxZkZwjcRkYPYPkONqJgDqd2jRTP8c%7C04441e5096ef211a79ba62f83e5cf34e1c9cfeffeb9c1933877f6231dc71d0de'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Cookie - HTTP - MDN Web Docs
The Cookie HTTP request header contains stored HTTP cookies associated with the server (i.e. previously sent by the server with the ...
Read more >HTTP headers | Cookie - GeeksforGeeks
HTTP headers are used to pass additional information with HTTP response or HTTP requests. A cookie is an HTTP request header i.e. used...
Read more >How are cookies passed in the HTTP protocol? - Stack Overflow
Cookies are passed as HTTP headers, both in the request (client -> server), and in the response ...
Read more >Manually setting a cookie in your script - Loadster
First of all, click the Add… menu on the step you want to add the cookie for, and choose Add request header. Adding...
Read more >Chapter 5. Cookies and response headers - CORS in Action
This chapter will introduce two new response headers: Access-Control-Allow-Credentials, which indicates that cookies may be included with requests, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Diizzayy Many thanks for your thorough answer, this is great support ! I’ll let you know if I don’t manage…
Hello, @Diizzayy, thanks for the answer.
My application is multitenancy. So, when I make a request, is needed to put an special header to specify what tenant I want to download the API schema. So, I would be greatfull if you allow to put it on requests. If you preffer, I can make a PR.