rollup-plugin-serve icon indicating copy to clipboard operation
rollup-plugin-serve copied to clipboard

Route api calls to backend

Open cjh9 opened this issue 7 years ago • 6 comments

Great plugin! Is it possible to route API-calls to the real backend, for instance localhost:3000 like this https://vuejs-templates.github.io/webpack/proxy.html?

cjh9 avatar Jan 20 '18 22:01 cjh9

Currently it's not, but I will accept PRs that implement options from webpack-dev-server or a subset thereof.

thgh avatar Jan 22 '18 14:01 thgh

It would be awesome if can set proxy in this plugin😁

hronro avatar Mar 26 '18 12:03 hronro

Has anyone pr this feature?

christiangelone avatar May 16 '19 01:05 christiangelone

@thgh, Would you be interested in a primitive version of the proxy feature as a start. I have it working right now, but only for the

serve({
  proxy: {
    api: 'http://localhost:7777'
  }
}

syntax. The advanced syntax wouldn't be much more difficult to implement, but I don't have the bandwidth right now.

calebdwilliams avatar Jul 24 '19 19:07 calebdwilliams

any update on this?

i was using @calebdwilliams's fork, but things did not quite work out when was using busboy. would love to see any implementation

hyperupcall avatar Sep 24 '19 20:09 hyperupcall

FWIW, I've been using @pearofducks rollup-plugin-dev and it's been working splendidly for me -- https://github.com/pearofducks/rollup-plugin-dev

I come from webpack and this has been a great transition from WDS! This is how I use it in rollup.config.js:

plugins: [
	....

	// In dev mode, serve API under a proxy, so we needn't inject
	// api url into the app.
	!production && dev({
		dirs: ['public'],
	 	port: 3000,
 		proxy: { '/api/*': 'http://localhost:12345/' },
 		spa: true,
	}),

	....
]

krishnagopinath avatar May 05 '20 19:05 krishnagopinath