express

Heroku only displaying backend of MERN app. How can I fix this?

送分小仙女□ 提交于 2021-02-10 06:27:19
问题 I've finished working on my first MERN app. It works locally and it was 'successfully built' on Heroku but all that is displayed is the backend-data retrieved for the '/' route from MongoDB. I've looked at a couple of resources that discuss deploying MERN stack apps to Heroku here: 1. https://www.freecodecamp.org/forum/t/solved-deployment-problem-showing-backend/280178 2. https://www.freecodecamp.org/news/how-to-deploy-a-react-app-with-an-express-server-on-heroku-32244fe5a250/ I've tried

Passport authentication callback hangs

偶尔善良 提交于 2021-02-10 04:35:52
问题 After hours trying to solve this by myself I reach to SO community looking for some light. I'm using passport for user authentication. It's already initialized in my main express.js file as per the docs: app.use(passport.initialize()); I got a index.js file which handles facebook-passport in this manner: Index.js 'use strict'; import express from 'express'; import passport from 'passport'; import auth from '../auth.service'; let router = express.Router(); //this function is defined in the

How to handle React Router with Node Express routing

夙愿已清 提交于 2021-02-10 04:14:02
问题 I am trying to manage a react app with react router and node js server my router in react : <BrowserRouter> <Switch> <PrivateRoute token={token} Component={Payments} exact path="/payments"/> <PrivateRoute token={token} Component={User} exact path="/user"/> <PrivateRoute token={token} Component={User} exact path=""/> <PrivateRoute token={token} Component={User} exact path="/"/> </Switch> <BrowserRouter/> export const PrivateRoute = ({Component, ...rest,token}) => { return ( <Route {...rest}

How to handle React Router with Node Express routing

时间秒杀一切 提交于 2021-02-10 04:12:24
问题 I am trying to manage a react app with react router and node js server my router in react : <BrowserRouter> <Switch> <PrivateRoute token={token} Component={Payments} exact path="/payments"/> <PrivateRoute token={token} Component={User} exact path="/user"/> <PrivateRoute token={token} Component={User} exact path=""/> <PrivateRoute token={token} Component={User} exact path="/"/> </Switch> <BrowserRouter/> export const PrivateRoute = ({Component, ...rest,token}) => { return ( <Route {...rest}

node.js的express框架

这一生的挚爱 提交于 2021-02-09 15:31:29
1.我选择了eclipse。 当然可能更多的人喜欢用webstorm,这都不是关键 首先在eclipse中安装一下node插件, 然后选择eclipse marketplace,搜索node,会有很多Node插件可供选择, 我选择的是 。 2. new一个node.js express project。 项目结构: node_modules: Web项目的模块管理,即你有任何的模块都有应该封装后放在此处,如连接数据库模块。 public: 该文件夹下还有三个文件夹images,javascripts,stylesheets,含义很明显了,就不说了吧。 routes: 路由规则,即Web的控制器,即mvc中的controller。 views: 视图,但是这种视图并不是传统的html文件,而是html的引擎模板,这里默认的模板是jade文件,可以认为是前台UI,当然你在新建node.js express project的时候可以选择jade或者是ejs。 app.js: myFirstWeb的入口,packege.json里有定义 "start": "node app.js",这里很有必要把app.js代码解读一遍: /** * Module dependencies. */ var express = require('express') , routes = require('.

Query parameters in Express

只愿长相守 提交于 2021-02-09 11:12:01
问题 I am trying to get access to query parameters using Express in Node.js. For some reason, req.params keeps coming up as an empty object. Here is my code in server.js : const express = require('express'); const exphbs = require('express-handlebars'); const bodyParser = require('body-parser'); const https = require('https'); //custom packages .. //const config = require('./config'); const routes = require('./routes/routes'); const port = process.env.port || 3000; var app = express(); /

Query parameters in Express

旧巷老猫 提交于 2021-02-09 11:11:23
问题 I am trying to get access to query parameters using Express in Node.js. For some reason, req.params keeps coming up as an empty object. Here is my code in server.js : const express = require('express'); const exphbs = require('express-handlebars'); const bodyParser = require('body-parser'); const https = require('https'); //custom packages .. //const config = require('./config'); const routes = require('./routes/routes'); const port = process.env.port || 3000; var app = express(); /

Node.js express app keep crashing on heroku

假如想象 提交于 2021-02-08 20:00:48
问题 I pushed a fairly simple node.js express app on heroku and can't make it works. It immeadiately crash. heroku tail --logs gives me : 2017-05-23T04:43:08.156660+00:00 app[api]: Scaled to web@1:Free worker@0:Free by user jp@yetie.fr 2017-05-23T04:43:24.388293+00:00 heroku[web.1]: Starting process with command `: node server.js` 2017-05-23T04:43:26.207926+00:00 heroku[web.1]: Process exited with status 0 2017-05-23T04:43:26.220393+00:00 heroku[web.1]: State changed from starting to crashed 2017

Firebase - TypeError: Path must be a string. Received undefined

六月ゝ 毕业季﹏ 提交于 2021-02-08 15:47:06
问题 I am just starting up with firebase. i am not sure ins and out of the firebase and based on my vaguely understanding, I have configured my app this way. In the main Index.js file, I am requiring const path = require('path') const firebaseConfig = require("./src/config/firebaseConfig.js") const firebaseDb = require("./src/helperFunctions/firebase_db.js") Here, firebaseConfig is the place where I am configuring my firebase const firebaseConfigJSON = require("./functions-config.json") const

How to call an api from another api in expressjs?

眉间皱痕 提交于 2021-02-08 15:22:27
问题 I have an api like this: app.get('/test', (req, res) => { console.log("this is test"); }); and another api: app.get('/check', (req, res) => { //I want to call "test" api without redirect to it. }); I want to call "test" api in "check" api without redirect to "test" api, just do the function in the "test" api. Above is the example code. 'Cause I dont' want to rewrite function from "test" api to "check" 回答1: Simple solution is to define a method which can be called using both request routes.