0

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.

enter image description here

enter image description here

Here is the code I use in App.js

enter image description here

Is there anyone that knows how I can fix this? Much appreciated

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Chance
  • 38
  • 3

1 Answers1

0

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.

Hrishikesh Kokate
  • 1,065
  • 1
  • 8
  • 22
  • What is a way to avoid this in the future? Does netlify allow for http requests instead of using graphql to create and update data? – Chance Jul 06 '22 at 03:45
  • Basically, if you want a server running, Netlify is not a solution for you in any means, at least not at the moment. As I've said above, Netlify will serve static files, so you're limited to client-side JS. You can add server-side functionality by using SSR, but if you wish to keep your GraphQL instance alive, that's not possible. The solution is to host your GraphQL instance elsewhere like Heroku and use Netlify redirects/rewrites to proxy to that, or directly connect to your Heroku instance using standard HTTP URLs. – Hrishikesh Kokate Jul 06 '22 at 06:12