Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 获取getStaticProps Next.js中的TLS错误_Reactjs_Axios_Next.js_Server Side Rendering_Getstaticprops - Fatal编程技术网

Reactjs 获取getStaticProps Next.js中的TLS错误

Reactjs 获取getStaticProps Next.js中的TLS错误,reactjs,axios,next.js,server-side-rendering,getstaticprops,Reactjs,Axios,Next.js,Server Side Rendering,Getstaticprops,我在组织的代理下工作,使用Next.js(npm运行开发) 对请求使用axios 客户端上的所有请求都可以正常工作,但在getStaticProps axios request func中出现getting错误 “在建立安全TLS连接之前已断开客户端网络套接字” getStaticProps export const getStaticProps: GetStaticProps = async (context) => { try { const pageContent = a

我在组织的代理下工作,使用Next.js(npm运行开发)

对请求使用axios

客户端上的所有请求都可以正常工作,但在getStaticProps axios request func中出现getting错误

“在建立安全TLS连接之前已断开客户端网络套接字”

getStaticProps

export const getStaticProps: GetStaticProps = async (context) => {
  try {
    const pageContent = await fetcher(API_METHODS.GET_PAGE_CONTENT, {
      data: { path: "/" },
    });
    return {
      props: { data: pageContent },
    };
  } catch (err) {
    console.log(err);
    return {
      redirect: { destination: "/500" },
    };
  }
};
取数器

export const fetcher = async (
  url: string,
  options: AxiosRequestConfig = {}
) => {
  const result = await axios
    .request({
      method: "post",
      url: `${API_ENDPOINT}/${url}`,
      ...options,
    })
    .catch((err: any) => {
      throw err;
    });
  return result.data;
};
在代理之外(在自己的PC上测试),一切都很好

我已经尝试过,但它没有帮助:

  • NODE\u TLS\u REJECT\u UNAUTHORIZED=0添加到
    .env.local

  • 正在尝试在axios配置中设置此选项

    {
    httpsAgent:
      new https.Agent({
        rejectUnauthorized: false
      });
    }