express

Cookies don't transfered in react and express.js

江枫思渺然 提交于 2020-01-16 08:46:54
问题 I have been working on project which backend uses express and apollo server and front end uses react js. Locally everything seems fine as server runs on port 2000 and react js runs on 3000. After building my react app I copied everything and place them server's public folder but after uploading them to remote server users can't authenticate since session id is not get transferred. Here is how I have configured base url in react app. App.js let BASE_URL = '' let WS_BASE_URL = '' let

Is there any need to authenticate a socket.io connection if it has a shared session with express?

社会主义新天地 提交于 2020-01-16 08:41:12
问题 I have seen this question and answer, which explains how to share sessions with Socket.IO 1.x and Express 4.x and this blog which suggests the use of socketio-auth. Is there a need to use both approaches for authentication if you are already sharing sessions with express. Does it add any security advantage? 回答1: If you already have an authenticated session via http in Express, then a socket.io connection is really JUST another http connection (it actually starts with an http connection and is

Android WebView “Trust anchor for certification path not found” for LetsEncrypt cert

不问归期 提交于 2020-01-16 08:15:10
问题 I have a web site being served over SSL from node.js. When I visit the site with a web browser (both on the Desktop, and Android). everything is fine - the lock appears indicating that the site is secure, when I inspect the certificates is valid and everything looks ok. That should mean the server is set up correctly, right? However, when I try to use an Android WebView for the exact same site, the page fails to load - I don't even see a request for the web page in my logs. Andr, after

Get Id for item in EJS template and inject into service

…衆ロ難τιáo~ 提交于 2020-01-16 06:08:07
问题 I am trying to figure out how to pass an Id into my PlayerDetailController and then use it in my service. I have the following route in my main app.js : var players = require('./routes/players'); app.use('/players', players); And I have the following routes inside of the players route ( routes/players.js ): var express = require('express'); var router = express.Router(); /* GET /players listing. */ router.get('/', function(req, res, next) { res.render('players', { title: 'Players', action:

Stream MongoDB results to Express response

浪子不回头ぞ 提交于 2020-01-16 06:05:25
问题 I am trying to do this without and 3rd party dependencies, as I don't feel they should be needed. Please note, due to architect ruling we have to use MongoDB native, and not Mongoose (don't ask!). Basically I have a getAll function, that will return all documents (based on passed in query) from a single collection. The number of documents, could easily hit multiple thousand, and thus, I want to stream them out as I receive them. I have the following code: db.collection('documents') .find

Stream MongoDB results to Express response

这一生的挚爱 提交于 2020-01-16 06:04:40
问题 I am trying to do this without and 3rd party dependencies, as I don't feel they should be needed. Please note, due to architect ruling we have to use MongoDB native, and not Mongoose (don't ask!). Basically I have a getAll function, that will return all documents (based on passed in query) from a single collection. The number of documents, could easily hit multiple thousand, and thus, I want to stream them out as I receive them. I have the following code: db.collection('documents') .find

express.js CSURF cookie and header match, returning 403

て烟熏妆下的殇ゞ 提交于 2020-01-16 05:39:30
问题 I have a simple express server setup like: app.use(bodyParser.json()); app.use(cookieParser()); app.use(csurf({ cookie: true })); // routes app.use(Routes imported from another file); The client is currently just a simple form in react. I am loading some initial data before the react app loads and the csrf cookie is being set there. I have a simple function for parsing the csrf cookie client side. I'm proxying the express server in create-react-app so I can't just set a meta tag in the header

express.js CSURF cookie and header match, returning 403

狂风中的少年 提交于 2020-01-16 05:39:06
问题 I have a simple express server setup like: app.use(bodyParser.json()); app.use(cookieParser()); app.use(csurf({ cookie: true })); // routes app.use(Routes imported from another file); The client is currently just a simple form in react. I am loading some initial data before the react app loads and the csrf cookie is being set there. I have a simple function for parsing the csrf cookie client side. I'm proxying the express server in create-react-app so I can't just set a meta tag in the header

Can someone explain this : EventEmitter causes failure when global variable

强颜欢笑 提交于 2020-01-16 05:30:49
问题 I spent a while trying to diagnose this error. First I had created a subclass of EventEmitter File Client.js var bindToProcess = function(fct) { if (fct && process.domain) { return process.domain.bind(fct) } return fct }; function Client(){ EventEmitter.call(this); } util.inherits(Client, EventEmitter); Client.prototype.success = function(fct) { this.on('success', bindToProcess(fct)) return this; } Client.prototype.login = function(username, password) { body = { username : username, password

Why does this node.js callback not run immediately?

淺唱寂寞╮ 提交于 2020-01-16 04:18:33
问题 Using the express-generator it spits out some error handling code like this: app.use('/', routes); app.use('/users', users); // catch 404 and forward to error handler app.use(function(req, res, next) { var err = new Error('Not Found'); err.status = 404; next(err); }); // error handlers // development error handler // will print stacktrace if (app.get('env') === 'development') { app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message,