question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I have an issue when trying to use a proxy. I have a server.js file with express that is using port 5000, and im running CRA in port 3000. Im pretty sure im using CRA v2+ (actually I used the command create react app just today)

Initially my package json (in the client) had this line

"proxy": "http://localhost:5000"

I deleted and replace it with the setupProxy (I installed the npm dependency on my client package.json) file with the following:

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

The file its placed inside appRootFolder/client/src.

When I run the app I noticed that im getting 404 in the routes

capture2

But if I add again the proxy line in my package json, its working

capture

The proxy middleware is running right? Because it shows the complete route though strangely is not working. Am I missing something? This is the route in my server.js

app.get('/api/site/site_data',(req,res)=>{
  Site.find({}, (err, site) => {
      if(err) return res.status(400).send(err);
      res.status(200).send(site[0].siteInfo)
  });
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Timercommented, Nov 27, 2018

Meaning api/* matches: api/test api/foo

But does not match: api/foo/bar

Using api/** will match: api/test api/foo api/foo/bar

😄

See https://github.com/isaacs/node-glob for a more full explanation.

0reactions
Timercommented, Nov 27, 2018

Ah, then yes the ** will fix it. ** says “all subpaths”, * is only a one-level path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "There is something wrong with the proxy server ...
Method 3: Checking your Proxy Settings · On your keyboard, press Windows Key+S. · Type “control panel” (no quotes), then hit Enter. ·...
Read more >
Common Proxy Problems (And How You Can Fix Them)
Common Proxy Issues and Causes · 1. Too many website IP bans · 2. Proxy provider failing · 3. Proxies not configured for...
Read more >
How to Fix “There Is Something Wrong With the Proxy Server ...
Go to the Control Panel. · Click on Internet Options. · Click on LAN (Local Area Network) Settings. · Uncheck the box that...
Read more >
Proxy Errors -Types and How to resolve it | By Limeproxies
Proxy errors are the main root cause are server problems. The error message is being retrieved from the large scale Internet network to...
Read more >
FIX: Unable to Connect to proxy server in Windows 10/11
1. Reset Internet options · 2. Disable proxy · 3. Use a VPN · 4. Use ipconfig command · 5. Reset Chrome settings...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found