res.cookie not working with apollo-server-express Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!graphql-tester (unit tests) with Graphql Apollo ServerReact Apollo Client not sending cookiesapollo-client does not work with CORSGraphQL Error Handling with ApolloClient and Apollo-Server-Expressusing apollo, cookie in response header but not being setGraphql Apollo Client issue : [Network error]: SyntaxError: Unexpected end of JSON inputSession cookie is not set in browserGraphql-yoga server on zeit return cors errorPass Provider info to Apollo ServerGraphQL: Cannot read response headers in Apollo Client
Simulate round-robin tournament draw
Does using the Inspiration rules for character defects encourage My Guy Syndrome?
Why did Europeans not widely domesticate foxes?
Preserving file and folder permissions with rsync
What is ls Largest Number Formed by only moving two sticks in 508?
Putting Ant-Man on house arrest
What is /etc/mtab in Linux?
My admission is revoked after accepting the admission offer
Why would the Overseers waste their stock of slaves on the Game?
Why is water being consumed when my shutoff valve is closed?
What is the purpose of the side handle on a hand ("eggbeater") drill?
TV series episode where humans nuke aliens before decrypting their message that states they come in peace
When does Bran Stark remember Jamie pushing him?
Bright yellow or light yellow?
Coin Game with infinite paradox
Is there a way to fake a method response using Mock or Stubs?
What's called a person who work as someone who puts products on shelves in stores?
How can I wire a 9-position switch so that each position turns on one more LED than the one before?
What helicopter has the most rotor blades?
/bin/ls sorts differently than just ls
Has a Nobel Peace laureate ever been accused of war crimes?
What to do with someone that cheated their way though university and a PhD program?
How do I deal with an erroneously large refund?
What were wait-states, and why was it only an issue for PCs?
res.cookie not working with apollo-server-express
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!graphql-tester (unit tests) with Graphql Apollo ServerReact Apollo Client not sending cookiesapollo-client does not work with CORSGraphQL Error Handling with ApolloClient and Apollo-Server-Expressusing apollo, cookie in response header but not being setGraphql Apollo Client issue : [Network error]: SyntaxError: Unexpected end of JSON inputSession cookie is not set in browserGraphql-yoga server on zeit return cors errorPass Provider info to Apollo ServerGraphQL: Cannot read response headers in Apollo Client
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I've been trying to send a cookie back to the client from the server. I get the response data but i don't see "set-cookie" in the response headers
My Apollo Server Configuration:
const server = new ApolloServer(
typeDefs,
resolvers,
context: ( req, connection, res ) => (
dummyModels: dummyModels,
models: models,
req,
connection,
res,
currentUser: dummyModels.users[2],
dummyUsers: dummyModels.dummyUsers,
),
);
app.use(cors(
credentials: true,
origin: 'http://localhost:3000',
// preflightContinue: true,
));
My resolver:
login: async (parent, args, context) =>
const _include_headers = function(body, response, resolveWithFullResponse)
return 'headers': response.headers, 'data': body;
;
const loginRequestOptions =
method: 'POST',
uri: 'http://localhost:3000/incorta/authservice/login',
qs:
// access_token: 'xxxxx xxxxx', // -> uri + '?access_token=xxxxx%20xxxxx'
user: args.input.username,
pass: args.input.password,
tenant: args.input.tenantName,
,
transform: _include_headers,
json: true // Automatically parses the JSON string in the response
;
const loginResponse = await request(loginRequestOptions);
console.log(loginResponse);
context.res.cookie(
'JSESSIONID',
tough.Cookie.parse(loginResponse.headers['set-cookie'][0]).value,
// expires : new Date(Date.now() + 9999999),
// path: '/incorta/',
// HttpOnly: false,
// maxAge: 1000 * 60 * 60 * 24 * 99, // 99 days
,
);
context.res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
return loginResponse.data;
,
Note: i'm using request-promise-native to make the request
My Apollo Client Configuration:
const httpLink = createHttpLink(
uri: 'http://172.16.16.130:4000/graphql',
credentials: 'include',
fetchOptions:
credentials: 'include',
,
);
const wsLink = new WebSocketLink(
uri: 'ws://172.16.16.130:4000/graphql',
options:
reconnect: true,
connectionParams:
headers:
'x-user-header': localStorage.getItem('userObject'),
,
,
);
const terminatingLink = split(
// split based on operation type
( query ) =>
const kind, operation = getMainDefinition(query);
return kind === 'OperationDefinition' && operation === 'subscription';
,
wsLink,
httpLink,
);
const link = ApolloLink.from([terminatingLink]);
const cache = new InMemoryCache();
export const client = new ApolloClient(
link,
cache,
);
I have tried tinkering with options. i don't know what i'm missing here.
express graphql apollo-client apollo-server
add a comment |
I've been trying to send a cookie back to the client from the server. I get the response data but i don't see "set-cookie" in the response headers
My Apollo Server Configuration:
const server = new ApolloServer(
typeDefs,
resolvers,
context: ( req, connection, res ) => (
dummyModels: dummyModels,
models: models,
req,
connection,
res,
currentUser: dummyModels.users[2],
dummyUsers: dummyModels.dummyUsers,
),
);
app.use(cors(
credentials: true,
origin: 'http://localhost:3000',
// preflightContinue: true,
));
My resolver:
login: async (parent, args, context) =>
const _include_headers = function(body, response, resolveWithFullResponse)
return 'headers': response.headers, 'data': body;
;
const loginRequestOptions =
method: 'POST',
uri: 'http://localhost:3000/incorta/authservice/login',
qs:
// access_token: 'xxxxx xxxxx', // -> uri + '?access_token=xxxxx%20xxxxx'
user: args.input.username,
pass: args.input.password,
tenant: args.input.tenantName,
,
transform: _include_headers,
json: true // Automatically parses the JSON string in the response
;
const loginResponse = await request(loginRequestOptions);
console.log(loginResponse);
context.res.cookie(
'JSESSIONID',
tough.Cookie.parse(loginResponse.headers['set-cookie'][0]).value,
// expires : new Date(Date.now() + 9999999),
// path: '/incorta/',
// HttpOnly: false,
// maxAge: 1000 * 60 * 60 * 24 * 99, // 99 days
,
);
context.res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
return loginResponse.data;
,
Note: i'm using request-promise-native to make the request
My Apollo Client Configuration:
const httpLink = createHttpLink(
uri: 'http://172.16.16.130:4000/graphql',
credentials: 'include',
fetchOptions:
credentials: 'include',
,
);
const wsLink = new WebSocketLink(
uri: 'ws://172.16.16.130:4000/graphql',
options:
reconnect: true,
connectionParams:
headers:
'x-user-header': localStorage.getItem('userObject'),
,
,
);
const terminatingLink = split(
// split based on operation type
( query ) =>
const kind, operation = getMainDefinition(query);
return kind === 'OperationDefinition' && operation === 'subscription';
,
wsLink,
httpLink,
);
const link = ApolloLink.from([terminatingLink]);
const cache = new InMemoryCache();
export const client = new ApolloClient(
link,
cache,
);
I have tried tinkering with options. i don't know what i'm missing here.
express graphql apollo-client apollo-server
add a comment |
I've been trying to send a cookie back to the client from the server. I get the response data but i don't see "set-cookie" in the response headers
My Apollo Server Configuration:
const server = new ApolloServer(
typeDefs,
resolvers,
context: ( req, connection, res ) => (
dummyModels: dummyModels,
models: models,
req,
connection,
res,
currentUser: dummyModels.users[2],
dummyUsers: dummyModels.dummyUsers,
),
);
app.use(cors(
credentials: true,
origin: 'http://localhost:3000',
// preflightContinue: true,
));
My resolver:
login: async (parent, args, context) =>
const _include_headers = function(body, response, resolveWithFullResponse)
return 'headers': response.headers, 'data': body;
;
const loginRequestOptions =
method: 'POST',
uri: 'http://localhost:3000/incorta/authservice/login',
qs:
// access_token: 'xxxxx xxxxx', // -> uri + '?access_token=xxxxx%20xxxxx'
user: args.input.username,
pass: args.input.password,
tenant: args.input.tenantName,
,
transform: _include_headers,
json: true // Automatically parses the JSON string in the response
;
const loginResponse = await request(loginRequestOptions);
console.log(loginResponse);
context.res.cookie(
'JSESSIONID',
tough.Cookie.parse(loginResponse.headers['set-cookie'][0]).value,
// expires : new Date(Date.now() + 9999999),
// path: '/incorta/',
// HttpOnly: false,
// maxAge: 1000 * 60 * 60 * 24 * 99, // 99 days
,
);
context.res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
return loginResponse.data;
,
Note: i'm using request-promise-native to make the request
My Apollo Client Configuration:
const httpLink = createHttpLink(
uri: 'http://172.16.16.130:4000/graphql',
credentials: 'include',
fetchOptions:
credentials: 'include',
,
);
const wsLink = new WebSocketLink(
uri: 'ws://172.16.16.130:4000/graphql',
options:
reconnect: true,
connectionParams:
headers:
'x-user-header': localStorage.getItem('userObject'),
,
,
);
const terminatingLink = split(
// split based on operation type
( query ) =>
const kind, operation = getMainDefinition(query);
return kind === 'OperationDefinition' && operation === 'subscription';
,
wsLink,
httpLink,
);
const link = ApolloLink.from([terminatingLink]);
const cache = new InMemoryCache();
export const client = new ApolloClient(
link,
cache,
);
I have tried tinkering with options. i don't know what i'm missing here.
express graphql apollo-client apollo-server
I've been trying to send a cookie back to the client from the server. I get the response data but i don't see "set-cookie" in the response headers
My Apollo Server Configuration:
const server = new ApolloServer(
typeDefs,
resolvers,
context: ( req, connection, res ) => (
dummyModels: dummyModels,
models: models,
req,
connection,
res,
currentUser: dummyModels.users[2],
dummyUsers: dummyModels.dummyUsers,
),
);
app.use(cors(
credentials: true,
origin: 'http://localhost:3000',
// preflightContinue: true,
));
My resolver:
login: async (parent, args, context) =>
const _include_headers = function(body, response, resolveWithFullResponse)
return 'headers': response.headers, 'data': body;
;
const loginRequestOptions =
method: 'POST',
uri: 'http://localhost:3000/incorta/authservice/login',
qs:
// access_token: 'xxxxx xxxxx', // -> uri + '?access_token=xxxxx%20xxxxx'
user: args.input.username,
pass: args.input.password,
tenant: args.input.tenantName,
,
transform: _include_headers,
json: true // Automatically parses the JSON string in the response
;
const loginResponse = await request(loginRequestOptions);
console.log(loginResponse);
context.res.cookie(
'JSESSIONID',
tough.Cookie.parse(loginResponse.headers['set-cookie'][0]).value,
// expires : new Date(Date.now() + 9999999),
// path: '/incorta/',
// HttpOnly: false,
// maxAge: 1000 * 60 * 60 * 24 * 99, // 99 days
,
);
context.res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
return loginResponse.data;
,
Note: i'm using request-promise-native to make the request
My Apollo Client Configuration:
const httpLink = createHttpLink(
uri: 'http://172.16.16.130:4000/graphql',
credentials: 'include',
fetchOptions:
credentials: 'include',
,
);
const wsLink = new WebSocketLink(
uri: 'ws://172.16.16.130:4000/graphql',
options:
reconnect: true,
connectionParams:
headers:
'x-user-header': localStorage.getItem('userObject'),
,
,
);
const terminatingLink = split(
// split based on operation type
( query ) =>
const kind, operation = getMainDefinition(query);
return kind === 'OperationDefinition' && operation === 'subscription';
,
wsLink,
httpLink,
);
const link = ApolloLink.from([terminatingLink]);
const cache = new InMemoryCache();
export const client = new ApolloClient(
link,
cache,
);
I have tried tinkering with options. i don't know what i'm missing here.
express graphql apollo-client apollo-server
express graphql apollo-client apollo-server
asked Mar 22 at 14:58
BahaaZidanBahaaZidan
296
296
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302412%2fres-cookie-not-working-with-apollo-server-express%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302412%2fres-cookie-not-working-with-apollo-server-express%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown