netlify仅在部署时才会与 /graphql抛出404错误
几天前,我有一个我推到Heroku的应用程序,在该应用程序正常工作,但是部署该应用程序进行NetLify时,该应用程序会部署,但是GraphQL连接会引发404个错误。这是一些图像。
中使用的代码
是否有人知道我如何解决这个问题?非常感谢
I have an app which I had pushed to heroku a few days ago, where it works fine, but when deploying the app to Netlify, the app deploys but the graphQL connection throws a 404 error. Here are some images.
Here is the code I use in App.js
Is there anyone that knows how I can fix this? Much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NetLify不运行像Heroku这样的应用程序服务器,它仅运行静态文件服务器。从您的代码中,您似乎正在尝试提供一个可以连接到的应用程序,并为您提供GraphQL访问。这是在Netlify上不可能的,至少不是直接的。
NetLify当前在NetLify功能中提供的唯一类似服务器的解决方案。但是,默认情况下,这些限制为10秒,并提供一次性数据连接 - 您不能继续使用GraphQL。
因此,如果您的要求是保持GraphQL Server运行(例如,例如Gatsby在
Gatsby开发
中所做的事情),NetLify不是您的解决方案。如果您希望一次发送数据并添加一些服务器端处理,则可以查看NetLify功能。Netlify doesn't run a app server like Heroku, it only runs a static file server. From your code, it appears that you're trying to serve a app that you could connect to and provide yourself with GraphQL access. This is not possible on Netlify, at least not directly.
The only server-like solution that Netlify currently provides in Netlify Functions. However, those are limited to 10 sec by default and provide, one-time data connection - not something that you could keep on using for GraphQL.
So if your requirement is to keep the GraphQL server running (for example like what Gatsby does during
gatsby develop
), Netlify is not the solution for you. If you wish to send the data one-time and add some server-side processing, you can take a look at Netlify Functions.