-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proxy #55
Comments
I don't really think this should be the responsibility of the bundler... Can you just enable CORS and hit localhost:3001 directly? Alternatively, you could build your own small server with express and use parcel as a middleware. let Bundler = require('parcel-bundler');
let express = require('express');
let bundler = new Bundler('entry.html');
let app = express();
// define proxy routes here
app.use(bundler.middleware()); |
@devongovett I always use create-react-app proxy This allows me to use relative urls like |
@tb Oh - thats exactly what I want. Thx for the tip! |
It's not the responsibility of the bundler, but it would be a very useful feature for the dev server. If your server is not in NodeJS (and you don't want to enable CORS), then without this you have to use some kind of post-processing to replace "locaholhost:PORT" with something else when deploying to production. It's much nicer to be able to use relative links and have the dev server have a config to proxy to the appropriate backend endpoint. |
For the dev-server, I think this would be useful for non-spa sites as well (php applications, etc). Where you proxy the app ( |
Hey @webular , you can probably use browser-sync and http-proxy-middleware to achieve your end goal and it's relatively easy to set it up. E.g.
|
An complete example with express
|
@albinotonnina oh~good example, but how can i use parcel no cache in this example ? like this : |
|
For those still needing more help, the socketio example chat app altered to bundle the client-side files: |
Hi @NullVoxPopuli, |
It would be a very useful feature for spa. |
@albinotonnina nice example~ but i want to set --open parameters in const bundler = new Bundler(proxypath, {
open: true,
}) But this has no effect,how to do it? Thx~ |
For some reason Parcel's dev server automatically responds with the header |
Is there a way to define a proxy? In webpack we are doing something like this:
More details about webpack's devserver proxy here.
The text was updated successfully, but these errors were encountered: