So my Apollo graphql server was working perfectly in development. I just deployed my project to Heroku, and now I receive a 503 error when making any queries.
I am able to get into the graphiql sandbox, but those responses come back as:
SyntaxError: Unexpected token < in JSON at position 0
I am using express for my server, and here is what the code looks like:
app.use(cors());
app.use(
'/graphql',
graphqlHTTP({
schema: pgSchema,
graphiql: true
})
);
app.use(express.static('../public'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../public', 'index.html'));
});
Here is where I connect my Apollo client in the React project:
const client = new ApolloClient({
uri: '/graphql'
});
function App() {
return (
<ApolloProvider client={client}>
<Router>
<Route exact path='/' component={Login} />
<Route exact path='/home' component={Home} />
</Router>
</ApolloProvider>
);
}
Here are my heroku logs from graphql:
2020-03-31T16:41:23.780542+00:00 heroku[router]: at=info method=POST path="/graphql" host=damp-ravine-76294.herokuapp.com request_id=a9e695db-63eb-476a-950f-a5d6561ff85f fwd="76.116.11.127" dyno=web.1 connect=1ms service=21ms status=200 bytes=21933 protocol=https
2020-03-31T16:45:50.392011+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/graphql" host=damp-ravine-76294.herokuapp.com request_id=650a1d7d-7f9e-4c66-8a5d-000fc60ed29a fwd="76.116.11.127" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
Please let me know if you have any ideas. Thanks!