dhatGuy/PERN-Store

Proxy error: Could not proxy request /api/products/?page=1 from localhost:3000 to http://localhost:9000

rkscodes opened this issue · 5 comments

I am just trying to run this project first, but I get this error and product wouldn't load on the page, though I have not setup .env because there are lot of them and I have no idea which ones is required, but this error seems unrelated though.

Most of the variables in the server's env file are needed. The api url and stripe secret key in the client's env file are important.
Can you setup the variables and tell me if it works?

Yeah actually I tried few things

  1. I removed "proxy": "http://localhost:9000" line from PERN-Store/client/package.json
  2. Added a new file SetupProxy.js in Client folder with following code.

const proxy = require('http-proxy-middleware'); module.exports = function(app) { app.use(proxy('/auth/google', { target: 'http://localhost:9000/' } )); }

It resolved the proxy error though still no products were displayed on homepage. Here is a screenshot of products loading and console.
image

  1. Then I tried to setup those variables but I see Postgress and I am having hard time figuring it out, I have only used MongoDB, if you could give me some pointer on how to do it it would be great.

  2. REACT_APP_API_URL in client env I don't understand what to fill here.

You might want to go through this youtube tutorial to get at least basic knowledge of postgresql.

Yeah thanks, got it now it's working. But still npmrun build doesn't work from root folder, it has same error. So, I have to do both separate npm run in client and server folder and then it works fine.

I'm currently AFK and for the next few weeks. I'll check the build script as soon as I'm back