express

node and reactjs axios server request returning index.html file instead of json

为君一笑 提交于 2020-08-22 07:09:06
问题 I have setup my project with a react frontend being compiled by webpack and the server running on node and express. When I deploy to production my requests to the server are returning the index.html file in the 'dist' folder rather than the json with the data. My webpack compiled output is at the location ./dist. Here is the routing part of my server.js file: if (process.env.NODE_ENV === 'production') { app.use(express.static('dist')); const path = require('path'); app.get('/', (req, res) =>

What am I missing about express sessions and cookies?

与世无争的帅哥 提交于 2020-08-22 04:33:49
问题 I've gotten pretty far with express and express-session and express-sql-session. I've got it creating a row in the database for a session when a user logs in. This is how I set it: //login route handler this.bcrypt.compare(password, row.hashed, function(err, passwordsMatch) { if (passwordsMatch === true) { console.log("user now logged in"); req.session.user = row; req.session.success = 'User successfully logged in'; res.send(row); res.end(); } }); Hunky dory! I can hop into my session table

What am I missing about express sessions and cookies?

こ雲淡風輕ζ 提交于 2020-08-22 04:32:50
问题 I've gotten pretty far with express and express-session and express-sql-session. I've got it creating a row in the database for a session when a user logs in. This is how I set it: //login route handler this.bcrypt.compare(password, row.hashed, function(err, passwordsMatch) { if (passwordsMatch === true) { console.log("user now logged in"); req.session.user = row; req.session.success = 'User successfully logged in'; res.send(row); res.end(); } }); Hunky dory! I can hop into my session table

What am I missing about express sessions and cookies?

耗尽温柔 提交于 2020-08-22 04:31:59
问题 I've gotten pretty far with express and express-session and express-sql-session. I've got it creating a row in the database for a session when a user logs in. This is how I set it: //login route handler this.bcrypt.compare(password, row.hashed, function(err, passwordsMatch) { if (passwordsMatch === true) { console.log("user now logged in"); req.session.user = row; req.session.success = 'User successfully logged in'; res.send(row); res.end(); } }); Hunky dory! I can hop into my session table

Mongoose Schema for geoJson coordinates

末鹿安然 提交于 2020-08-21 17:00:18
问题 I tried to create a schema for geojson but have had some problems with syntax for coordinates. Here's my current code: var DataSchema = new Schema({ properties: { title: { type: String, required: true }, description: { type: String, required: true }, date: { type:Date, default:Date.now } }, geometry: { coordinates: [] } }); I tried using [] (empty array), it creates '' and [Number,Number] but it doesn't work. My question is: how do I have to construct my schema so as result I will get

Mongoose Schema for geoJson coordinates

て烟熏妆下的殇ゞ 提交于 2020-08-21 16:59:51
问题 I tried to create a schema for geojson but have had some problems with syntax for coordinates. Here's my current code: var DataSchema = new Schema({ properties: { title: { type: String, required: true }, description: { type: String, required: true }, date: { type:Date, default:Date.now } }, geometry: { coordinates: [] } }); I tried using [] (empty array), it creates '' and [Number,Number] but it doesn't work. My question is: how do I have to construct my schema so as result I will get

Secure GraphQL queries with express js, passport s

穿精又带淫゛_ 提交于 2020-08-21 06:55:41
问题 I have started using graphql in my express js project but i am wondering how to protect some of my GraphQL query. Previously i used passport js(JWT) for this and that works great. It was really easy to secure route but with graphql(express-graphql) i couldn't find any solution. Furthermore it will be nice to have some kind of role based solution to protect particular fields. Is there any good tutorial how to secure graphQL ? 回答1: Last I checked there weren't any really good tutorials out

Access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response

空扰寡人 提交于 2020-08-20 11:32:30
问题 I have prepared an Lambda function using Express(node.js) and enabled the Authorization with IAM as well. The API is working in the Postman as per below link : https://www.youtube.com/watch?v=KXyATZctkmQ&t=35s As I'm fairly new with CORS policy and API concepts. I'm trying to access the sample using Ajax call. So far I have prepared the Authorization Header as per documentation and few reference. Git Repo Link : https://github.com/mudass1r/aws-iam-authorization.git Reference Link for

Why is my sinon stub acting like it's calling the real function?

你离开我真会死。 提交于 2020-08-20 10:33:05
问题 I'm trying to follow this example: https://www.alexjamesbrown.com/blog/development/stubbing-middleware-testing-express-supertest/ but the sinon stub doesn't seem to be executing the wrapped code. I've seen lots of stackoverflow posts regarding this issue but none of the answers have helped me figure out what I'm doing wrong. Whenever I run my test I get the following error: 1) should return a list of sites 0 passing (42ms) 1 failing GET /api/config/buildPro/sites should return a list of sites

Unhandled Error gets thrown in Firebase Cloud Functions

你离开我真会死。 提交于 2020-08-19 17:40:25
问题 I'm using Firebase Cloud Functions, and in one of my projects I have a simple function that looks like the following: exports.responseGiven = functions.https.onCall(async (data, context) => { if (!context.auth) { throw new functions.https.HttpsError( 'permission-denied', 'Must be an user to execute this action' ); } const studentPath = data.studentPath; const eventPath = data.eventPath; const isUpdating = data.isUpdating; const studentDoc = await admin.firestore().collection('students').doc(