I’m using React + Webpack and i have Lambda working great with them when deployed to Netlify. But i can’t get them to work on dev (my Mac) at the same time.
I thought i need to use this: “dev”: “npm start; npm run start:lambda”, but when i run this, only the React dev server runs, but after i do CTRL + C the React dev closes and then Lambda runs.
"scripts": {
"start": "webpack-dev-server --config config/webpack.dev.js",
"build": "webpack --config config/webpack.prod.js --no-source-maps",
"dev": "npm start; npm run start:lambda",
"prod": "npm run build; npm run build:lambda",
"start:lambda": "netlify-lambda serve functions",
"build:lambda": "netlify-lambda build functions"
},
I have tried creating a proxy function in /functions
folder, but not working.
const proxy = require('http-proxy-middleware')
module.exports = (app) => {
app.use(
proxy('/.netlify/functions/', {
target: 'http://localhost:9000/',
pathRewrite: {
'^/\\.netlify/functions': '',
},
}),
)
}
Then i tried editing my Webpack dev config so added this, but still nothing:
devServer: {
proxy: {
'/.netlify': {
target: 'http://localhost:9000',
pathRewrite: { '^/.netlify/functions': '' },
},
},
Any tips?