grand-stack-starter
grand-stack-starter copied to clipboard
Problem deploying with Zeit Now/Vercel
I've run into an issue with deploying to Zeit now. They updated their platform to v2 and now when I deploy I just get a set of static files on Zeit now.
Using this as a sample, I was able to deploy the api
part of the app.
I created a now.json
file in the project's root:
{
"version": 2,
"builds": [
{ "src": "./api/src/index.js", "use": "@now/node-server" }
],
"routes": [
{ "src": "/.*", "dest": "/api/src/index.js" }
]
}
This is using @now/node-server
which Zeit doesn't seem to really want you to use. I think changes could be made to use @now/node
(my hunch is api/src/index.js
would need to do be set up like an Apollo Lamda function).
If you want to add environmental variables to talk to you can do something like:
{
"version": 2,
"builds": [
{ "src": "./api/src/index.js", "use": "@now/node-server" }
],
"routes": [
{ "src": "/.*", "dest": "/api/src/index.js" }
],
"env": {
"NEO4J_URI": "bolt://localhost: 7687",
"NEO4J_USER": "neo4j",
"NEO4J_PASSWORD": "letmein",
"GRAPHQL_LISTEN_PORT": "4000"
}
}
To get the playground to work when I deployed I also had to update the creation of the ApolloServer
:
// api/src/index.js
const server = new ApolloServer({
context: { driver },
schema: schema,
introspection: true,
playground: true,
});
With these changes, I was able to deploy with now
and connect to a playground that was connected to my sandbox DB.
I was unable to get the routes
in now.json
to do something like have the server run at /api
. This may have something to do with how @now/node-server
works, but I'm not sure.
Because of the issue with nesting deploying the UI part gets a little weird, so I tried making a separate now.json
file in the ui
directory following this guide. Unfortunately, I ran up against this open issue. It looks like a fix may be incoming though.
Hi @tmr08c . Is your build of api still running?
I've got as far as building 'successfully' (ie without build errors) (I didn't add a route, but the explorer serves from src/index.js).
The ENV variables only seem to be picked up from the now.json file (which is fine, there is some older documentation from Zeit about passing these and secrets with an -e parameter at build time or apply them after a restart which I haven't tested yet).
But the explorer is not finding the Apollo server. I've tried various configs for initialising and connecting explorer to the api (localhost, 0.0.0.0, 127.0.0.1, the zeit app url). At one point logs suggested the server was exposing port 4000, but before I added the env variables it appeared to be starting on a high port (35***) and now I'm a bit confused about exactly what is happening in this build process, so any pointers welcome.
This is a great project ./ stack and super easy just to fire up with Gitpod and a neo4j sandbox, build and enjoy, all for that lovely 'free' word.
It's a bit of a let down having to bash the brain with config for a third party tool and a world of difference if it was the one click process it could/should/will I'm sure be when I work it out!
Alternatively has anyone built a heroku? (for the server - I would be very happy to keep the front-end separate and sure there are plenty of options for this)
Even more alternatively, [in the rest of my spare time :)] I was thinking to look at a serverless implementation and spin up the server as a firebase cloud function: there are various examples of doing this with express out there, but if anyone's there already with this stack...??
[edit] Like this maybe: https://github.com/Rusfighter/firegraph see blog article: https://itnext.io/serverless-graphql-with-free-cdn-in-memory-caching-766c1e29376a
Hi folks, this may be fixed based on https://github.com/grand-stack/grand-stack-starter/pull/58 .
Think this is good to go, but I'll double check next week.