I'm trying to find an easy way to set up a path-based proxy for development purposes, similar to what you would do with NGINX. I work at a corporate environment where my team has a React component, specifically a support chat widget, which is used by different teams on our site. This widget communicates with its own backend, but when we run local instances of the pages, they often don't set up the necessary proxy routing that would normally occur in production. Currently, we have to conditionally hard-code API URLs based on the hostname, which isn't user-friendly since developers might have different setups. I'm looking for a quick way, possibly a Chrome extension, to create a proxy that allows proper API routing regardless of how the users set up their local environments. Any suggestions would be appreciated!
3 Answers
If you’re using Vite in those projects, you can leverage its built-in proxy feature. It simplifies the setup for forwarding requests during development and should match your requirements nicely!
You could try using Caddy for that purpose. It's pretty straightforward and can handle routing easily. Just set it up to forward the requests to your backend without requiring any complex configurations from your users.
If you’re looking for community input, you might want to check out this Discord server where developers share similar issues. It could lead to more tailored solutions for your setup!

Unfortunately, not all projects use Vite. Some don’t even have a bundler set up, which makes it tough to implement that proxy feature.