是什么导致代理停止在React应用程序中工作?

发布于 2025-01-22 13:02:46 字数 393 浏览 4 评论 0原文

我的React/FastApi应用程序具有代理

代理”:“ http:// localhost:8000

在我的软件包中

。 (500)在位置0 的JSON中意外的令牌P

我尝试了

http://127.0.0.1:8000

用于代理和同样的问题。

我检查了Fastapi后端,一切正常。如果我将整个路径放在获取中,那就没问题了。

我知道该错误是否说意外的令牌<,那么这意味着我会恢复一些HTML而不是JSON,但我不知道p在此错误中意味着什么。

我升级了节点。这可能是错误的原因吗?什么是什么突破代理?

谢谢

My React/FastAPI application had proxy

proxy": "http://localhost:8000

in my package.json working fine but now the proxy doesn't work and I get back

Internal Server Error (500) Unexpected token P in JSON at position 0

I tried

http://127.0.0.1:8000

for proxy and the same problem.

I checked the FastAPI backend and everything works fine. If I put the whole path inside fetch, then there is no problem.

I know if the error said Unexpected token < then that means I got back some HTML instead of JSON but I don't know what the P means in this error.

I upgraded Node. Could that be the cause of the error? What exactly breaks proxy?

Thank you

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

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

发布评论

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

评论(1

蹲墙角沉默 2025-01-29 13:02:46

看来Node v17.xx正在引起我的代理问题。我降级到v16.14.2(大约是我在更新/升级之前的版本),并且问题消失了。
我将看看情况如何,但是关于节点v17的某些内容正在引起代理问题。

It appears that Node v17.x.x was causing problems with my proxy. I downgraded to v16.14.2 (which was approximately the version that I had before the update/upgrade) and the problems are gone.
I am going to see how it goes but something about node v17 is causing problems with proxy.

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