我正在尝试在netlify-dev
我的 gatsby 项目中使用它们的无服务器功能。
这是我的netlify.toml
文件
[build]
functions = "lambda"
command = "gatsby build"
[dev]
command = "gatsby develop"
functionsPort = 34567
port = 8000
publish = "public"
targetPort = 8000
我将此添加到我的 Gatsby 配置中
const proxy = require("http-proxy-middleware")
module.exports = {
developMiddleware: app => {
app.use(
"/.netlify/functions/",
proxy({
target: "http://localhost:34567",
pathRewrite: {
"/.netlify/functions/": "",
},
})
)
},
//...
但是,端口似乎有问题我每次运行时总是得到一个新的随机端口netlify dev
Netlify Dev ◈
◈ Injected build setting env var: CLOUDINARY_CLOUD_NAME
◈ Injected build setting env var: CLOUDINARY_API_KEY
◈ Injected build setting env var: CLOUDINARY_SECRET
◈ Starting Netlify Dev with gatsby
Waiting for localhost:8000.
◈ Lambda server is listening on 61271 //*** I would expect this to be 34567? ***
success open and validate gatsby-configs - 0.066s
⠋ load plugins
我在这里想念什么?为什么端口总是不同的?