Vercel: [dev] Now dev fails to serve api functions when used with Gridsome

Created on 4 Jan 2020  Â·  3Comments  Â·  Source: vercel/vercel

Following the Gridsome example project and executing now dev will lunch the Gridsome Dev mode but the Now api functions will be ignored.

A solution is to remove the dev script from the package.json, but it is not clear then if its a bug or a missconfiguration as the documentation and the example encourages setting the script.

bug dev

Most helpful comment

The latest now dev (17.0.2) doesn't work with Gridsome projects before going to project settings and changing the framework preset from Vue to Gridsome.

After that, however, now devstarts both Gridsome and api functions but while the proxy address is at port 3000, Gridsome still thinks that it's running in a totally different port so you end up seeing the wrong dev URLs after the server has started. (This latter issue should maybe be fixed w/ gridsome serve as well.)

So the current workaround is just to remember the port 3000 and you're golden :)

Here's a debug log from me starting a project where it works OK in port 3000, but only thing you see after the command has finshed (as Gridsome "helpfully" cleans up all console messages) is "Site running at http://localhost:55620/" (even though the correct URL is http://localhost:3000/

 Projects/GitHub/og-image-builder î‚° î‚  master î‚° now dev --debug
> [debug] [2020-02-07T17:45:28.875Z] Found config in file /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/now.json
Now CLI 17.0.2 dev (beta) — https://zeit.co/feedback
> [debug] [2020-02-07T17:45:28.919Z] user supplied known subcommand
> [debug] [2020-02-07T17:45:28.939Z] Spinner invoked (Retrieving scope…) with a 1000ms delay
> [debug] [2020-02-07T17:45:29.955Z] Spinner ended (Retrieving scope…)
> [debug] [2020-02-07T17:45:30.119Z] Spinner invoked (Retrieving project…) with a 1000ms delay
> [debug] [2020-02-07T17:45:30.121Z] GET https://api.zeit.co/projects/QmU1frWd5aJTJ642yhKuZMn7YX5Mr3kK1BN85KVfMzmtgt?
> [debug] [2020-02-07T17:45:30.768Z] GET https://api.zeit.co/projects/QmU1frWd5aJTJ642yhKuZMn7YX5Mr3kK1BN85KVfMzmtgt? : 645.811ms
> [debug] [2020-02-07T17:45:30.769Z] Spinner ended (Retrieving project…)
> [debug] [2020-02-07T17:45:30.793Z] The yarn executable is already cached, not re-downloading
> [debug] [2020-02-07T17:45:30.796Z] Reading `package.json` file
> [debug] [2020-02-07T17:45:30.797Z] Reading `now.json` file
> [debug] [2020-02-07T17:45:30.798Z] Searching files inside of /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/
> [debug] [2020-02-07T17:45:33.375Z] Found 27948 and filtered out 27898 files
> [debug] [2020-02-07T17:45:33.390Z] Using local env: /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.env
> [debug] [2020-02-07T17:45:33.407Z] Locating files /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder
> [debug] [2020-02-07T17:45:33.407Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.DS_Store
> [debug] [2020-02-07T17:45:33.407Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.cache
> [debug] [2020-02-07T17:45:33.407Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.env
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.env.example
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.git
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.gitignore
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.now
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/node_modules
> [debug] [2020-02-07T17:45:33.409Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/dist/.DS_Store
> [debug] [2020-02-07T17:45:33.409Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/src/.DS_Store
> [debug] [2020-02-07T17:45:33.410Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/static/.DS_Store
> [debug] [2020-02-07T17:45:33.410Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/dist/img/.DS_Store
> [debug] [2020-02-07T17:45:33.411Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/src/assets/.DS_Store
> [debug] [2020-02-07T17:45:33.411Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/static/img/.DS_Store
> [debug] [2020-02-07T17:45:33.418Z] Locating files /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder: 10.970ms
> [debug] [2020-02-07T17:45:33.435Z] No Runtimes need to be installed
> [debug] [2020-02-07T17:45:33.751Z] Adding build match for "api/search"
> [debug] [2020-02-07T17:45:33.752Z] Adding build match for "api/track"
> Running Dev Command “gridsome develop -p $PORT”
> [debug] [2020-02-07T17:45:33.828Z] Starting dev command with parameters : {"cwd":"/Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder","devCommand":"gridsome develop -p 55620","port":55620}
> [debug] [2020-02-07T17:45:33.830Z] Spawning dev command: npx --no-install gridsome develop -p 55620
Gridsome v0.7.12

Initializing plugins...
Load sources - 0s
Create GraphQL schema - 0.05s
Create pages and templates - 0.09s
Generate temporary code - 0.06s
Bootstrap finish - 2.45s
> [debug] [2020-02-07T17:45:37.702Z] Filesystem watcher notified of 7 events
> [debug] [2020-02-07T17:45:37.704Z] File modified: src/.temp/config.js
> [debug] [2020-02-07T17:45:37.705Z] File modified: src/.temp/constants.js
> [debug] [2020-02-07T17:45:37.705Z] File modified: src/.temp/plugins-server.js
> [debug] [2020-02-07T17:45:37.706Z] File modified: src/.temp/icons.js
> [debug] [2020-02-07T17:45:37.706Z] File modified: src/.temp/routes.js
> [debug] [2020-02-07T17:45:37.706Z] File modified: src/.temp/now.js
> [debug] [2020-02-07T17:45:37.706Z] File modified: src/.temp/plugins-client.js
> [debug] [2020-02-07T17:45:37.707Z] Reading `package.json` file
> [debug] [2020-02-07T17:45:37.707Z] Reading `now.json` file
> [debug] [2020-02-07T17:45:37.708Z] Searching files inside of /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/
32% building 185/217 modules 32 active ...inen/LocalDocuments/Projects/GitHub/og-image-builder/node_modules/core-js/modules/_array-species-constructor.js> Ready! Available at http://localhost:3000
42% building 273/282 modules 9 active /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/node_modules/core-js/library/fn/symbol/index.js> [debug] [2020-02-07T17:45:40.958Z] Found 27948 and filtered out 27898 files
51% building 349/359 modules 10 active ...2-oneOf-1-2!/Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/node_modules/tailwindcss/tailwind.css> [debug] [2020-02-07T17:45:41.430Z] No builders were updated


 DONE  Compiled successfully in 8602ms                                                                                                          7:45:46 PM


  Site running at:
  - Local:                 http://localhost:55620/
  - Network:               http://192.168.1.111:55620/

  Explore GraphQL data at: http://localhost:55620/___explore

All 3 comments

The latest now dev (17.0.2) doesn't work with Gridsome projects before going to project settings and changing the framework preset from Vue to Gridsome.

After that, however, now devstarts both Gridsome and api functions but while the proxy address is at port 3000, Gridsome still thinks that it's running in a totally different port so you end up seeing the wrong dev URLs after the server has started. (This latter issue should maybe be fixed w/ gridsome serve as well.)

So the current workaround is just to remember the port 3000 and you're golden :)

Here's a debug log from me starting a project where it works OK in port 3000, but only thing you see after the command has finshed (as Gridsome "helpfully" cleans up all console messages) is "Site running at http://localhost:55620/" (even though the correct URL is http://localhost:3000/

 Projects/GitHub/og-image-builder î‚° î‚  master î‚° now dev --debug
> [debug] [2020-02-07T17:45:28.875Z] Found config in file /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/now.json
Now CLI 17.0.2 dev (beta) — https://zeit.co/feedback
> [debug] [2020-02-07T17:45:28.919Z] user supplied known subcommand
> [debug] [2020-02-07T17:45:28.939Z] Spinner invoked (Retrieving scope…) with a 1000ms delay
> [debug] [2020-02-07T17:45:29.955Z] Spinner ended (Retrieving scope…)
> [debug] [2020-02-07T17:45:30.119Z] Spinner invoked (Retrieving project…) with a 1000ms delay
> [debug] [2020-02-07T17:45:30.121Z] GET https://api.zeit.co/projects/QmU1frWd5aJTJ642yhKuZMn7YX5Mr3kK1BN85KVfMzmtgt?
> [debug] [2020-02-07T17:45:30.768Z] GET https://api.zeit.co/projects/QmU1frWd5aJTJ642yhKuZMn7YX5Mr3kK1BN85KVfMzmtgt? : 645.811ms
> [debug] [2020-02-07T17:45:30.769Z] Spinner ended (Retrieving project…)
> [debug] [2020-02-07T17:45:30.793Z] The yarn executable is already cached, not re-downloading
> [debug] [2020-02-07T17:45:30.796Z] Reading `package.json` file
> [debug] [2020-02-07T17:45:30.797Z] Reading `now.json` file
> [debug] [2020-02-07T17:45:30.798Z] Searching files inside of /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/
> [debug] [2020-02-07T17:45:33.375Z] Found 27948 and filtered out 27898 files
> [debug] [2020-02-07T17:45:33.390Z] Using local env: /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.env
> [debug] [2020-02-07T17:45:33.407Z] Locating files /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder
> [debug] [2020-02-07T17:45:33.407Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.DS_Store
> [debug] [2020-02-07T17:45:33.407Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.cache
> [debug] [2020-02-07T17:45:33.407Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.env
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.env.example
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.git
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.gitignore
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/.now
> [debug] [2020-02-07T17:45:33.408Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/node_modules
> [debug] [2020-02-07T17:45:33.409Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/dist/.DS_Store
> [debug] [2020-02-07T17:45:33.409Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/src/.DS_Store
> [debug] [2020-02-07T17:45:33.410Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/static/.DS_Store
> [debug] [2020-02-07T17:45:33.410Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/dist/img/.DS_Store
> [debug] [2020-02-07T17:45:33.411Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/src/assets/.DS_Store
> [debug] [2020-02-07T17:45:33.411Z] Ignoring /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/static/img/.DS_Store
> [debug] [2020-02-07T17:45:33.418Z] Locating files /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder: 10.970ms
> [debug] [2020-02-07T17:45:33.435Z] No Runtimes need to be installed
> [debug] [2020-02-07T17:45:33.751Z] Adding build match for "api/search"
> [debug] [2020-02-07T17:45:33.752Z] Adding build match for "api/track"
> Running Dev Command “gridsome develop -p $PORT”
> [debug] [2020-02-07T17:45:33.828Z] Starting dev command with parameters : {"cwd":"/Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder","devCommand":"gridsome develop -p 55620","port":55620}
> [debug] [2020-02-07T17:45:33.830Z] Spawning dev command: npx --no-install gridsome develop -p 55620
Gridsome v0.7.12

Initializing plugins...
Load sources - 0s
Create GraphQL schema - 0.05s
Create pages and templates - 0.09s
Generate temporary code - 0.06s
Bootstrap finish - 2.45s
> [debug] [2020-02-07T17:45:37.702Z] Filesystem watcher notified of 7 events
> [debug] [2020-02-07T17:45:37.704Z] File modified: src/.temp/config.js
> [debug] [2020-02-07T17:45:37.705Z] File modified: src/.temp/constants.js
> [debug] [2020-02-07T17:45:37.705Z] File modified: src/.temp/plugins-server.js
> [debug] [2020-02-07T17:45:37.706Z] File modified: src/.temp/icons.js
> [debug] [2020-02-07T17:45:37.706Z] File modified: src/.temp/routes.js
> [debug] [2020-02-07T17:45:37.706Z] File modified: src/.temp/now.js
> [debug] [2020-02-07T17:45:37.706Z] File modified: src/.temp/plugins-client.js
> [debug] [2020-02-07T17:45:37.707Z] Reading `package.json` file
> [debug] [2020-02-07T17:45:37.707Z] Reading `now.json` file
> [debug] [2020-02-07T17:45:37.708Z] Searching files inside of /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/
32% building 185/217 modules 32 active ...inen/LocalDocuments/Projects/GitHub/og-image-builder/node_modules/core-js/modules/_array-species-constructor.js> Ready! Available at http://localhost:3000
42% building 273/282 modules 9 active /Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/node_modules/core-js/library/fn/symbol/index.js> [debug] [2020-02-07T17:45:40.958Z] Found 27948 and filtered out 27898 files
51% building 349/359 modules 10 active ...2-oneOf-1-2!/Users/uninen/LocalDocuments/Projects/GitHub/og-image-builder/node_modules/tailwindcss/tailwind.css> [debug] [2020-02-07T17:45:41.430Z] No builders were updated


 DONE  Compiled successfully in 8602ms                                                                                                          7:45:46 PM


  Site running at:
  - Local:                 http://localhost:55620/
  - Network:               http://192.168.1.111:55620/

  Explore GraphQL data at: http://localhost:55620/___explore

I tried with the latest Now CLI and used now init gridsome && cd gridsome to start a new project.

When I ran now, it correctly identified the project as Gridsome.

Auto-detected project settings (Gridsome):
- Build Command: `gridsome build` or `build` from `package.json`
- Output Directory: dist
- Development Command: gridsome develop -p $PORT

Then I ran npm install followed by now dev and it seemed to work too, I just had to scroll up to see the output from Now instead of the output from Gridsome.

now dev
Now CLI 17.0.4 (beta) — https://zeit.co/feedback
> Running Dev Command “gridsome develop -p $PORT”
Gridsome v0.6.9

Initializing plugins...
Initialize - 0.97s
Load sources - 0s
Create GraphQL schema - 0.22s
Create pages and templates - 0.05s
Generate code - 0.04s
Bootstrap finish - 1.28s
10% building 1/1 modules 0 active> Ready! Available at http://localhost:3000

Maybe we need to make the URL clearer because http://localhost:3000 is from now dev but the other URL is printed from Gridsome http://localhost:65350 and it will not work with Serverless Functions (because Gridsome doesn't support functions).

This has been fixed in the canary channel.

Try it out with npm i -g now@canary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rowno picture Rowno  Â·  3Comments

davidbillamboz picture davidbillamboz  Â·  3Comments

jstejada picture jstejada  Â·  4Comments

pex picture pex  Â·  3Comments

koljakutschera picture koljakutschera  Â·  3Comments