I have deploy both https://github.com/cheatcode/nodejs-server-boilerplate and https://github.com/cheatcode/nextjs-boilerplate on different servers but I am having problems with the authentication flow. The login method requires setting a cookie for authentication token but when server and client on cross domain, it is not able to set the cookie. Therefore I have put the client files under backend/client and redirected all traffic except api/graphql to client/build/index.html with the following code.
app.use(express.static('client/build'));
app.get('/api/graphql', (req, res) => {
//What to do here to direct traffic to graphql server
});
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + 'client/build/index.html'));
});
But I couldn't find a way to direct api/graphql to the graphql server.
is there a better approach?
I have deploy both https://github.com/cheatcode/nodejs-server-boilerplate and https://github.com/cheatcode/nextjs-boilerplate on different servers but I am having problems with the authentication flow. The login method requires setting a cookie for authentication token but when server and client on cross domain, it is not able to set the cookie. Therefore I have put the client files under
backend/clientand redirected all traffic exceptapi/graphqltoclient/build/index.htmlwith the following code.But I couldn't find a way to direct
api/graphqlto the graphql server.is there a better approach?