food-lookup-demo-rails
food-lookup-demo-rails copied to clipboard
Proxy not working
Tried on react-scripts version 0.2.3 and 0.7.0. In both cases, proxy doesn't work and API calls go to localhost:3000 instead of localhost:3001. Anyone else run into this?
Hi @pkpp1233,
Thanks for your patience. Updating the repo now to 0.7.0. Still, I'm not sure what you're running into -- on a fresh install of master I don't have any issues. Were you trying this on a clean version of master or your own fork? If this is still a problem, would you mind providing more info?
@acco @pkpp1233 I seem to have a similar issue (maybe?) my proxy runs on port 3100 rather than 3001? Not really sure why as my Procfile is:
web: cd client && npm start
api: bundle exec rails s -p 3001
And the output of rake start is:
Running via Spring preloader in process 31341
16:21:17 web.1 | started with pid 31342
16:21:17 api.1 | started with pid 31343
16:21:18 web.1 |
16:21:18 web.1 | > [email protected] start /Users/will/Labs/ruby/food-demo/client
16:21:18 web.1 | > react-scripts start
16:21:18 web.1 |
16:21:19 web.1 | Starting the development server...
16:21:19 web.1 |
16:21:19 api.1 | => Booting Puma
16:21:19 api.1 | => Rails 5.0.1 application starting in development on http://localhost:3001
16:21:19 api.1 | => Run `rails server -h` for more startup options
16:21:19 api.1 | Puma starting in single mode...
16:21:19 api.1 | * Version 3.7.0 (ruby 2.2.2-p95), codename: Snowy Sagebrush
16:21:19 api.1 | * Min threads: 5, max threads: 5
16:21:19 api.1 | * Environment: development
16:21:19 api.1 | * Listening on tcp://0.0.0.0:3100
16:21:19 api.1 | Use Ctrl-C to stop
16:21:24 web.1 | Compiled successfully!
16:21:24 web.1 |
16:21:24 web.1 | The app is running at:
16:21:24 web.1 |
16:21:24 web.1 | http://localhost:3000/
16:21:24 web.1 |
16:21:24 web.1 | Note that the development build is not optimized.
16:21:24 web.1 | To create a production build, use npm run build.
So I changed my client/package.json to reflect this as:
{
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3100/",
"devDependencies": {
"react-scripts": "0.8.5"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
And it works… ¯\_(ツ)_/¯
Hi @willwright82 -- hmmm. I noticed you're using Puma. On the one hand, it says this:
16:21:19 api.1 | => Rails 5.0.1 application starting in development on http://localhost:3001
But then later it says this:
16:21:19 api.1 | * Listening on tcp://0.0.0.0:3100
As you say: ¯\_(ツ)_/¯
The -p flag may not be a valid way to set the port for Puma and Puma is using 3100 by default
I updated to Rails 5 and tested everything again -- still works fine for me
Thanks @acco — Will play around with it and see. 🤔
If you haven't solved this yet, as I remember, the version of Puma (3.4?) that originally shipped with Rails 5.0.1 did not allow you to override the port number correctly. There were actually a couple of buggy versions of Puma as this kept coming back.....again, as I remember. It has been a while since I tried Rails 5.0
I just built the project from scratch with Rails 5.1.3 and Puma 3.7 and everything works correctly.