Proxy error: Could not proxy request /api/profile/all from localhost:3000 to http://localhost:5000. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET)
Hi I was wondering if anyone knows the solution to this problem. The application was working just fine yesterday, but today it started raising this error up. Please I desperately need help. I have to finish this project before the 5th of February.
//package.json(Node)
{
"name": "devconnector",
"version": "1.0.0",
"description": "Social network for developers",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run client\" \"npm run server\""
},
"author": "Brad Traversy",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.2",
"concurrently": "^3.5.1",
"express": "^4.16.3",
"gravatar": "^1.6.0",
"jsonwebtoken": "^8.2.0",
"moment": "^2.24.0",
"mongoose": "^5.0.12",
"npm": "^6.5.0",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"validator": "^9.4.1"
},
"devDependencies": {
"nodemon": "^1.17.3"
}
}
//package.json(React)
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#fortawesome/fontawesome": "^1.1.8",
"#fortawesome/react-fontawesome": "^0.1.3",
"axios": "^0.18.0",
"classnames": "^2.2.5",
"jwt-decode": "^2.2.0",
"moment": "^2.22.0",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-html-table-to-excel": "^2.0.0",
"react-moment": "^0.7.0",
"react-redux": "^5.0.7",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.4",
"react-table": "^6.8.6",
"reactstrap": "^7.0.2",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000"
}
Related
Hi i have a server with multiple subdomain a weird issue started when all domains returned with 502 bad gateway i entered one subdomain and i run npm run dev and it worked but all the remain subdomains still 502, when i go to other subdomain and run npm start the subdomain work while all the other return 502 what should i do.
here's my package for web (on a subdomain)
{
"name": "mmy-route-web",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 8080",
"build": "next build",
"start": "next start"
},
"dependencies": {
"#fortawesome/free-solid-svg-icons": "^5.15.4",
"#fortawesome/react-fontawesome": "^0.1.16",
"#glidejs/glide": "^3.4.0",
"#mailchimp/mailchimp_marketing": "^3.0.43",
"#popperjs/core": "^2.9.2",
"#stripe/stripe-js": "^1.13.2",
"bootstrap": "^5.0.0-beta3",
"cloudinary-build-url": "^0.2.1",
"cloudinary-react": "^1.7.0",
"cookie": "^0.4.1",
"html-react-parser": "^1.2.6",
"lodash": "^4.17.21",
"next": "10.0.9",
"next-iron-session": "^4.1.12",
"nookies": "^2.5.2",
"npm": "^8.1.0",
"parse": "^3.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-use-tawk": "^1.0.0",
"sass": "^1.32.8",
"stripe": "^8.145.0",
"styled-components": "^5.2.1",
"swr": "^0.5.5"
},
"browser": {
"child_process": false
}
}
and for my backend (on other subdomain):
{
"name": "parse-server-example",
"version": "1.4.0",
"description": "An example Parse API server using the parse-server module",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/"
},
"license": "MIT",
"dependencies": {
"#parse/fs-files-adapter": "^1.2.0",
"concurrently": "^7.0.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"jimp": "^0.16.1",
"kerberos": "0.0.24",
"nodemailer": "^6.4.17",
"parse": "~1.8.0",
"parse-dashboard": "^2.1.0",
"parse-server": "*",
"parse-server-cloudinary-adapter": "^1.4.0",
"parse-server-dedicated-email-adapter": "^3.0.6",
"parse-server-email-template-adapter": "^1.0.2",
"parse-server-generic-email-adapter": "0.0.4",
"parse-smtp-template": "^2.2.0",
"slugify": "^1.4.6"
},
"scripts": {
"start": "node index.js",
"dev": "concurrently \"cd server && npm run start\" \"npm run start\""
},
"engines": {
"node": ">=4.3"
}
}
I'm trying to build a react components library (e.g Buttons, Modals, etc.)
But until now I still cannot figure how to do nested imports
the objective that i want to have is to be able to do this
import Something from '#company/moduleName/Something'
here is my package.json
{
"name": "#company/moduleName",
"version": "1.0.0",
"description": "company's react design system",
"author": "",
"license": "",
"repository": "",
"main": "dist/index.js",
"module": "dist/index.modern.js",
"source": "src/index.js",
"engines": {
"node": ">=13",
"npm": ">=7"
},
"type": "module",
"exports": {
".": "./dist/index.modern.js",
"./Button": "./dist/Button.modern.js",
"./Container": "./dist/Container.modern.js",
"./Input": "./dist/Input.modern.js",
"./Modal": "./dist/Modal.modern.js",
"./Select": "./dist/Select.modern.js",
"./Separator": "./dist/Separator.modern.js",
"./Sidebar": "./dist/Sidebar.modern.js",
"./Tab": "./dist/Tab.modern.js",
"./TextArea": "./dist/TextArea.modern.js",
"./theme": "./dist/theme.modern.js",
"./Typography": "./dist/Typography.modern.js"
},
"scripts": {
"build": "microbundle src/*.js --no-compress --no-sourcemap -f modern,cjs",
"start": "microbundle src/*.js --no-compress --no-sourcemap -f modern,cjs watch",
"rename": "cd dist && ren *.modern.js *.js",
"prepare": "run-s build",
"test": "run-s test:unit test:lint test:build",
"test:build": "run-s build",
"test:lint": "eslint .",
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"predeploy": "cd example && npm install && npm run build",
"deploy": "gh-pages -d example/build"
},
"peerDependencies": {
"react": "^17.0.1",
"lodash.merge": "^4.6.2",
"react-icons": "^4.2.0",
"react-modal": "^3.12.1",
"react-select": "^4.1.0",
"styled-components": "^5.2.1"
},
"devDependencies": {
"babel-eslint": "^10.0.3",
"cross-env": "^7.0.2",
"env-cmd": "^10.1.0",
"eslint": "^7.21.0",
"eslint-config-prettier": "^6.7.0",
"eslint-config-standard": "^14.1.0",
"eslint-config-standard-react": "^9.2.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-standard": "^4.0.1",
"gh-pages": "^2.2.0",
"microbundle": "latest",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.4",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "^4.0.3",
"lodash.merge": "^4.6.2",
"react-icons": "^4.2.0",
"react-modal": "^3.12.1",
"react-select": "^4.1.0",
"styled-components": "^5.2.1"
},
"files": [
"dist"
],
}
currently i'm using microbundle to build everything in the src/ folder. I've added the exports field but it still says this in the example project inside the module
Module not found: Can't resolve '#company/moduleName/Button' in 'E:\Projects\Software\company\moduleName\example\src'
edit
To be clear, the dist folder shows up the correct desired result
-dist
index.modern.js
Modal.modern.js
...
I've also been able to do this, but this is not the desired output
#company/moduleName/dist/Something.modern
Any help would be greatly appreciated!
Need help to start nodejs server and next js app at the same time using concurrently npm package at our backend. I have written the script in package.json file on backend side but it's not working.
I don't know exactly know even the concurrently is exist for next js or not. The below script is working fine for React-App but not working for Next JS App
package.json (backend)
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node backend/server",
"server": "nodemon backend/server",
"client": "npm start --prefix frontend",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "",
"license": "ISC",
"dependencies": {
"#sendgrid/mail": "^7.4.0",
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-jwt": "^6.0.0",
"express-validator": "^6.6.1",
"formidable": "^1.2.2",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.20",
"mongoose": "^5.10.9",
"morgan": "^1.10.0",
"nodemon": "^2.0.5",
"shortid": "^2.2.15",
"slugify": "^1.4.5",
"string-strip-html": "^6.1.0"
},
"devDependencies": {
"concurrently": "^5.3.0"
}
}
package.json(frontend)
{
"name": "frontend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"proxy": "http://127.0.0.1:8000",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "next",
"build": "next build",
"start": "next start"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#zeit/next-css": "^1.0.1",
"aos": "^3.0.0-beta.6",
"isomorphic-fetch": "^3.0.0",
"js-cookie": "^2.2.1",
"jsonwebtoken": "^8.5.1",
"moment": "^2.29.1",
"next": "^9.5.5",
"nprogress": "^0.2.0",
"prop-types": "^15.7.2",
"query-string": "^6.13.6",
"react": "^16.14.0",
"react-bootstrap": "^1.4.0",
"react-dom": "^16.14.0",
"react-modal": "^3.11.2",
"react-quill": "^1.3.5",
"react-render-html": "^0.6.0",
"reactstrap": "^8.6.0"
}
}
In your package.json file of the backend, you need to replace
"client": "npm start --prefix frontend",
with
"client": "cd ./frontend && npm run dev"
I am assuming that your Nextjs app is in the frontend folder/directory. change the folder accordingly. Then you can run npm run dev command from the backend directory.
Now you will be able to start nodejs server and next js app at the same time using concurrently npm package
I am new to the entire MERN Stack process.
I am following the tutorial for a user login app here:
https://blog.bitsrc.io/build-a-login-auth-app-with-mern-stack-part-1-c405048e3669
I've reached the end of the tutorial, and I feel I am missing a crucial step. If I run
npm run dev
I can successfully view and use the app at
http://localhost:3000/
Here is the script for dev in my root package.json:
"dev": "concurrently \"npm run server\" \"npm run client\""
However, isn't it also supposed to work if I run
node server.js
If I do this, I get this error at localhost:5000
Cannot GET /
I have a proxy setting in my client's package.json is well. Isn't this supposed to let me access the full app at
localhost:5000
Here is my root package.json:
"name": "example",
"version": "1.0.0",
"description": "example",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "mystock",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"concurrently": "^4.0.1",
"express": "^4.16.4",
"is-empty": "^1.2.0",
"jsonwebtoken": "^8.3.0",
"mongoose": "^5.3.11",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"validator": "^10.9.0"
}}
Here is my client/package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"jwt-decode": "^2.2.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I'd appreciate any input!
I have a create-react-app project which proxies a node express server at port 5000.
When we deploy it locally, all the requests get routed from client to the backend server and intermediate pages get rendered properly.
However, when I deploy it to Heroku, the flow always has to start from / route as any other URL directly hits the express server instead of being routed from front end.
Eg: https://consumesafe-dev.herokuapp.com works
But https://consumesafe-dev.herokuapp.com/dashboard goes directly to the node server instead of being proxied from front end.
here is the package.json for server:
{
"name": "example-create-react-app-express",
"version": "1.0.0",
"scripts": {
"client": "cd client && yarn start",
"server": "nodemon server.js",
"test": "cd client && npm install && yarn test",
"dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\""
},
"dependencies": {
"#google-cloud/language": "^1.0.0",
"#google-cloud/vision": "^0.12.0",
"async": "^2.6.0",
"body-parser": "~1.4.2",
"express": "^4.16.2",
"google-cloud": "^0.57.0",
"https": "^1.0.0",
"method-override": "~2.0.2",
"nodemon": "^1.17.3",
"pg": "^7.4.1",
"request": "^2.83.0",
"sequelize": "^4.37.2",
"winston": "^2.4.1"
},
"devDependencies": {
"concurrently": "^3.5.1"
}
}
and the package.json from client:
{
"name": "example-create-react-app-express",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:5000/",
"dependencies": {
"bootstrap": "^3.3.7",
"firebase": "^3.6.1",
"material-ui": "^0.20.0",
"react": "^16.2.0",
"react-checkbox-group": "^4.0.1",
"react-dom": "^16.2.0",
"react-event-timeline": "^1.5.1",
"react-notification-system": "^0.2.17",
"react-router-dom": "^4.2.2"
},
"devDependencies": {
"react-scripts": "1.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}