尝试代理请求时 Gatsby 出错

发布于 2025-01-09 16:08:35 字数 720 浏览 0 评论 0原文

尝试通过 Gatsby 代理我的开发 URL 时出现错误。在我的 gatsby-config.js 中,我有:

  proxy: [
    {
      prefix: '/myaccount',
      url: 'https://www-dev.site.com',
    },
  ],

Gatsby 代理错误屏幕截图

尝试时出错将请求“/myaccount/”代理到“https://www-dev.site.com/myaccount/”写入 EPROTO 4584046080:error:14094458:SSL例程:ssl3_read_bytes:tlsv1无法识别的名称:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL警报号112

RequestError:写入EPROTO 4555591168:错误:14094458:SSL例程:ssl3_read_bytes:tlsv1无法识别的名称:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL警报号112

这正在工作,突然停止了。

I am getting an error when trying to proxy my dev url through Gatsby. In my gatsby-config.js I have:

  proxy: [
    {
      prefix: '/myaccount',
      url: 'https://www-dev.site.com',
    },
  ],

Gatsby Proxy Error Screenshot

Error when trying to proxy request "/myaccount/" to "https://www-dev.site.com/myaccount/" write EPROTO 4584046080:error:14094458:SSL routines:ssl3_read_bytes:tlsv1 unrecognized name:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 112

RequestError: write EPROTO 4555591168:error:14094458:SSL routines:ssl3_read_bytes:tlsv1 unrecognized name:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 112

This was working and all of a sudden stopped.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷鸟归林 2025-01-16 16:08:35

正如前面所说,这看起来像是一个证书问题(因为 SSL)。如果没有更多实现细节,很难猜测建议的解决方案是否适用于您的场景,但您可以尝试将安全性设置为 false (secure: false),以免拒绝自签名证书。在您的 gatsby-config.js 中:

const { createProxyMiddleware } = require("http-proxy-middleware") 

module.exports = {
  developMiddleware: app => {
    app.use(
      "/.netlify/functions/",
      createProxyMiddleware({
        target: "http://localhost:9000",
        secure: false, 
        pathRewrite: {
          "/.netlify/functions/": "",
        },
      })
    )
  },

文档:https://www.gatsbyjs.com/docs/api-proxy/#self-signed-certificates

调整它以适应您的需求,替换/.netlify/functions/ 用于您的 API 端点。

As it has been said, it looks like a certificate issue (because of the SSL). Without more implementation details it's difficult to guess if a proposed solution will work on your scenario but you can try setting the security as false (secure: false) to don't reject self-signed certificates. In your gatsby-config.js:

const { createProxyMiddleware } = require("http-proxy-middleware") 

module.exports = {
  developMiddleware: app => {
    app.use(
      "/.netlify/functions/",
      createProxyMiddleware({
        target: "http://localhost:9000",
        secure: false, 
        pathRewrite: {
          "/.netlify/functions/": "",
        },
      })
    )
  },

Docs: https://www.gatsbyjs.com/docs/api-proxy/#self-signed-certificates

Tweak it to adapt it to your needs, replacing /.netlify/functions/ for your API endpoint.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文