我将Gatsby与netlify-lambda一起使用,它为 9000 端口上的函数创建服务器:
http://localhost:9000/myFunctionName
在生产中,函数的地址是:
/.netlify/functions/myFunctionName
所以我想有一个开发模式代理,http://localhost:9000/
当我调用/.netlify/functions
.
我的自定义 Webpack 配置位于gatsby-node.js
:
exports.modifyWebpackConfig = ({ config, stage }) => {
if (stage === 'develop') {
config.merge({
devServer: {
proxy: {
'/.netlify/functions': {
target: 'http://localhost:9000',
pathRewrite: {
'^/\\.netlify/functions': ''
}
}
}
}
})
}
}
不工作。
我也试过这个https://www.gatsbyjs.org/docs/api-proxy/#api-proxy但我需要重写 url 而不仅仅是前缀。
将netlify-lambda与Gatsby一起使用的最佳方法是什么?
谢谢