-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
webpack-dev-server proxy dosen't work #458
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
Comments
when i set proxy option: |
@Authorlove try proxy: [{
path: `/v1/*`,
target: 'http://api.in.uprintf.com'
}], |
Have you had any luck getting HMR to work through a proxy? I kept noticing HMR was still sending through the original port when I tried this :( |
+1 Server.js:
The code inside app.all doesn't seem to run at all.. |
I'm experiencing a potentially related issue. I'm trying to use the rewrite option and the function I pass it does not seem to fire. I tested the code separately to make sure the function wasn't just working incorrectly and the code works. If the above comment is true and the code inside of app.all isn't firing that would explain my issue. But, definitely not ideal... |
Because I use nginx as my server, it needs Host header filed, so when i set changeOrigin: true, it works. And my case is done. |
Yo guys, let's try to change |
@vinhlh this saved me! Wish there was an upgrade doc for webpack 2.0. |
@vinhlh also worked for me. Neither of the following worked: But this does: 👍 |
May be helpful for some, in my case adding http:// and /** resolved my issues. |
@Authorlove can this be closed? |
Although this is closed issue, Need some guidance. I dont know how much I am screwing up. Can any one of you help me in my configuration, I wish to I am just suferring from trail of 404s. |
@pgangwani, Did you try without the trailing slash in |
That returns 404 . |
@pgangwani, yeah |
Can any one else help? |
@pgangwani
|
Not working. On Sep 1, 2016 12:10 AM, "Brad J" [email protected] wrote:
|
My config has stopped working after 6 months on an npm install. Reverting to 1.14.1 fixed the issue |
@pgangwani, I copy/pasted @bivvo's code in the |
Thanks @vinhlh. For others fiddling with this, here's what I ended up with to get hot module reloading working and still able to hit my API server: I began here: https://github.com/chimurai/http-proxy-middleware#context-matching, looking at pattern matching:
Initially it appeared that I could specify a quoted array as the key for the proxy property of the webpack config e.g. My solution was just to use whatever bits of the
Then, according to the
So any path not ending in these three extensions would match and thus be proxied. devServer: {
// progress: true,
hot: true,
inline: true,
// https: true,
// port: 8081,
contentBase: path.resolve(__dirname,'public'),
proxy: {
'!/**/*.{css,js,hot-update.json}': {
target: 'http://localhost:3000',
secure: false
// changeOrigin: true
}
}
}, There's surely a better way, but this is working for now. |
{"changeOrigin": true} works for me |
webpack-dev-server: 2.1.0-beta.9, webpack: 2.1.0-beta.25 and express for backend api server Objective is to redirect api requests from localhost:3000/api/* to localhost:3030/*. Followed the example in this repository as @SpaceK33z suggested. It worked for me with the following config (pathRewrite) :
|
@mproid that config worked for me too! var apiProxy = proxy('/api/**', {
target: 'https://api.instagram.com/v1/',
pathRewrite: {
"^/api": ""
},
changeOrigin: true,
logLevel: 'debug',
}); pathRewrite is a must here since we don't wont to prefix requests with an actual '/api' |
@bivvo |
I'm unable to get any of these options to work 👎 Here is my config at the moment:
My HTML markup contains a script tag that is looking for a local
What I would like and expect to happen is when I go to request What am I missing here? I'm also using the following: OSX and the exact error I'm getting is:
EDIT: I think I was expecting the opposite behavior for some weird reason. By proxying the web server through the dev server, I should still be using the dev server, not the actual server while developing. |
I've tried every combination here and none are working for me. Here's my config: const webpack = require("webpack");
const path = require("path");
const IS_DEV = process.env.NODE_ENV === "development";
module.exports = {
devtool: IS_DEV ? "inline-source-map" : "eval",
entry: "./src/index.js",
output: {
filename: "app.js",
path: path.resolve(__dirname, "dist")
},
resolve: {
modules: [
path.resolve(__dirname, "src"),
"node_modules"
],
extensions: [".json", ".js"]
},
module: {
rules: [
{
test: /\.html$/,
exclude: /node_modules/,
loader: "ractive-loader"
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}, {
test: /\.css$/,
exclude: /node_modules/,
loaders: [
"style-loader",
"css-loader"
]
}
]
},
devServer: {
contentBase: "./dist",
hot: true,
proxy: {
"/ext_api/**": {
target: "http://foo.bar/" // obscured to hide my employer
}
}
},
plugins: [new webpack.HotModuleReplacementPlugin()]
}; The response is a 502, cannotconnect |
Just to be explicit - In my case mistakenly i have placed proxy at the root however i was suppose to keep it in devServer here is my final configuration
|
npm install webpack -g after run these restart your pc, sometimes need to fresh all again. |
Ugh. None of this works:
The front end is at 8080 and the server at 3000. No combination of any of the suggestions have worked. Why is this so dinky? |
@luddens what are you trying to do here? This is more a matter of understanding and configuring https://github.com/chimurai/http-proxy-middleware than anything about webpack or this dev server. Here under path matching I see something similar to your example with |
Got the same problem. I solved this by removing setting of allowing CORS from the server and it works for me. |
@wulichenyang Yep that did it for me. Removed My webpack config looks like this: I'm on webpack-dev-server version 3.2.1 |
This should work:
|
Hi @pgangwani! If you resolved this issue, could you show me the solution, please? |
Hey what's the version of webpack you are using.
I would say answer will depend on that.
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Eugen <[email protected]>
Sent: Tuesday, June 30, 2020 11:02:21 AM
To: webpack/webpack-dev-server <[email protected]>
Cc: Tarun Juneja <[email protected]>; Comment <[email protected]>
Subject: Re: [webpack/webpack-dev-server] webpack-dev-server proxy dosen't work (#458)
Hi @pgangwani<https://github.com/pgangwani>! If you resolved this issue, could you show me the solution, please?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#458 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABQQYCHNQ3R4RUXIPLXWQMDRZF2GLANCNFSM4CBKLKXQ>.
|
Hi,
I'm using webpack v. 4.35.3
webpack-dev-server v. 3.7.2
,Regards
Evgenii Verhinin
…On Tue, Jun 30, 2020, 6:38 PM Tarun Juneja ***@***.***> wrote:
Hey what's the version of webpack you are using.
I would say answer will depend on that.
Get Outlook for Android<https://aka.ms/ghei36>
________________________________
From: Eugen ***@***.***>
Sent: Tuesday, June 30, 2020 11:02:21 AM
To: webpack/webpack-dev-server ***@***.***>
Cc: Tarun Juneja ***@***.***>; Comment <
***@***.***>
Subject: Re: [webpack/webpack-dev-server] webpack-dev-server proxy dosen't
work (#458)
Hi @pgangwani<https://github.com/pgangwani>! If you resolved this issue,
could you show me the solution, please?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<
#458 (comment)>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQQYCHNQ3R4RUXIPLXWQMDRZF2GLANCNFSM4CBKLKXQ
>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#458 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHKZQ3ELFLEGDCPAUO24HL3RZH2HBANCNFSM4CBKLKXQ>
.
|
I'm also having this trouble...
But I still get But, then when I run the backend code locally and use, it works.
I want to be able to work on the frontend without having to always spin up the server |
I want to proxy /v1/** to http://myserver.com, and here is my devServer configration,
but it results in 404 not found error, and here is the response,
It seems to proxy to my ubuntu nginx server, since i use mac os locally, but i don't use express in my remote server.
The text was updated successfully, but these errors were encountered: