express

How to access endpoint from express router in Cloud Functions Shell

半城伤御伤魂 提交于 2020-01-25 06:57:27
问题 (Note: I'm using javascript, not typescript in my Functions) My Firebase Project has a single 'oauth' function, which has a series of endpoints created through express app/routers. I don't understand how to run the functions at these endpoints from the Cloud Functions Shell to debug them locally. Here is my index.js const twitter = require("./oauth/twitter"); const app = express(); app.use("/signin/twitter", twitter.router); exports.oauth = functions.https.onRequest(app); My actual endpoints

sessions are not getting stored in the browser cookies

那年仲夏 提交于 2020-01-25 06:50:09
问题 When i trying to run my API in postman it is working fine and sessions are getting maintained. But when i am trying to run it from UI Part the login session is not working. This is my Login API from where i am login into app.post('/user/login', (req, res, next) => { const body = req.body; let email = body.email; let password = body.password; const userDetails = db.collection(userProfiles); userDetails.findOne({email: email}, function (err, user) { if (err) { return next(err); } else if (!user

How to set X-Forwarded-For in Node.Js app while calling with axios

烈酒焚心 提交于 2020-01-25 06:45:13
问题 Okay, I just got an opportunity to work in nodejs, where I am using axios library to fetch the data from third party url. Everything was working very smoothly until it was deployed to staging ENV. Similar issue I got while working with rails, and the solution I found was to use @request['X-Forwarded-For'] = 'XX.YYY.Z.Z' in header. Coming to the issue now, have already tried options = { headers: { 'X-Forwarded-For': 'XX.YYY.Z.Z' } } and its not working at all even at local env :/ axios.get(URL

JSON webtoken login authorisation for react and express protected routes

╄→尐↘猪︶ㄣ 提交于 2020-01-25 06:42:25
问题 I am struggling to make a login system using JSON web tokens. I have made the login (client side) that calls to my server.js file. This is the login through the client side Below is my handle submit function that calls the server.js login route.How would I use a token here? handleSubmit(e) { e.preventDefault(); if (this.state.email.length < 8 || this.state.password.length < 8) { alert(`please enter the form correctly `); } else { const data = { email: this.state.email, password: this.state

JSON webtoken login authorisation for react and express protected routes

冷暖自知 提交于 2020-01-25 06:41:31
问题 I am struggling to make a login system using JSON web tokens. I have made the login (client side) that calls to my server.js file. This is the login through the client side Below is my handle submit function that calls the server.js login route.How would I use a token here? handleSubmit(e) { e.preventDefault(); if (this.state.email.length < 8 || this.state.password.length < 8) { alert(`please enter the form correctly `); } else { const data = { email: this.state.email, password: this.state

JSON webtoken login authorisation for react and express protected routes

非 Y 不嫁゛ 提交于 2020-01-25 06:41:07
问题 I am struggling to make a login system using JSON web tokens. I have made the login (client side) that calls to my server.js file. This is the login through the client side Below is my handle submit function that calls the server.js login route.How would I use a token here? handleSubmit(e) { e.preventDefault(); if (this.state.email.length < 8 || this.state.password.length < 8) { alert(`please enter the form correctly `); } else { const data = { email: this.state.email, password: this.state

How to deploy express.js server to Netlify

故事扮演 提交于 2020-01-25 06:40:37
问题 I am attempting to deploy a Vue.js, Node, Express, MongoDB (MEVN) stack application to Netlify. I successfully deployed the front end of the application to Netlify, and am now attempting to deploy the express server, based on the following serverless-http example: https://github.com/neverendingqs/netlify-express/blob/master/express/server.js I configured my server to include the serverless-http package: server.js const express = require('express'); const app = express(); const serverless =

How to write clean, modular express.js applications

寵の児 提交于 2020-01-25 06:13:45
问题 Pretty much since forever, I've stayed away from NodeJS backend development for one reason and one reason only: Almost all Express projects I've started or I've been forced to maintain end up being a huge mess where the entire website is run on a single script that's +/- 5000 lines long. The the following example from the ExpressJS hello world page, in this form I'd end up adding more and more routes to app leading to a huge mess of code. var express = require('express'); var app = express();

How to write clean, modular express.js applications

瘦欲@ 提交于 2020-01-25 06:11:08
问题 Pretty much since forever, I've stayed away from NodeJS backend development for one reason and one reason only: Almost all Express projects I've started or I've been forced to maintain end up being a huge mess where the entire website is run on a single script that's +/- 5000 lines long. The the following example from the ExpressJS hello world page, in this form I'd end up adding more and more routes to app leading to a huge mess of code. var express = require('express'); var app = express();

Enabled CORS in node/express but getting “Response to preflight request doesn't pass access control check”

*爱你&永不变心* 提交于 2020-01-25 06:08:10
问题 I am getting the error : Failed to load http://localhost:3000/users/register: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. On the front end i'm using axios: const instance = axios.create({ baseURL: 'http://localhost:3000', timeout: 1000, headers: {"Access-Control-Allow-Origin": "*"} }); instance.post('/users/register').then((res) =>