Reactでpostを行い、Expressでそれを受け取るところでcorsの対策でプロキシを設定しようとしました。
localhost:8080/api/userをlocalhost:3000/api/userで受け取る
下記の内容だとエラーが出ないのですがコメントアウトしているところを足すとエラーが発生します。
改善策をご存知でしたら、よろしくお願いします。
const merge = require("webpack-merge"); const webpackConfig = require("./webpack.config.js"); module.exports = merge(webpackConfig, { mode: "development", contentBase: "http://localhost", //下記に二つをたすとエラーが発生 //port: 8080, //devServer: { proxy: { "/api": { target: "http://localhost:3000", }, }, }, });
Example app listening at http://:::3000 [0] ✖ 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. [0] - configuration has an unknown property 'port'. These properties are valid: [0] object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions? } [0] For typos: please correct them. [0] For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration. [0] Loaders should be updated to allow passing options via loader options in module.rules. [0] Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader: [0] plugins: [ [0] new webpack.LoaderOptionsPlugin({ [0] // test: /.xxx$/, // may apply this only for some modules [0] options: { [0] port: ... [0] } [0] }) [0] ] [0] npm ERR! code ELIFECYCLE [0] npm ERR! errno 1 [0] npm ERR! react-hogehoge-heroku@1.0.0 client: `webpack-dev-server --config ./config/webpack.config.dev.js --open --mode development` [0] npm ERR! Exit status 1 [0] npm ERR! [0] npm ERR! Failed at the react-hogehoge-heroku@1.0.0 client script. [0] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
あなたの回答
tips
プレビュー