nextJS:在 getserversideProps 中获取 api 时出现 403 错误

问题描述 投票:0回答:0

在 getServerSideProps 中获取时,它总是返回

error 403(Forbidden)

代码:

export const getServerSideProps: GetServerSideProps = async (ctx) => {
  const { uuid } = ctx.params;

  const res = await axios.get(
    `https://backend.gobot.id/api/v1/auth/forgot-password/${uuid}`
  );
  console.log(res.status);
  return {
    props: { uuid },
  };
};

退货

AxiosError:请求失败,状态码为 403

从外面

getServerSideProps
它工作正常。你能告诉我为什么会这样吗?
我应该配置下一个配置吗?

javascript reactjs next.js fetch next
© www.soinside.com 2019 - 2024. All rights reserved.