question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

now dev not serving serverless functions on Windows machine

See original GitHub issue

I haven’t been able to get serverless functions to work using now dev on my Windows machine.

Windows 10 node v10.16 yarn 1.19.1 now 16.3.1

I had tried a couple of different things with my own projects with no success so I turned to the example projects but I get the same results with them. I get the main app served from the default route (/) as expected but any requests to /api/* result in serving the content of the default route instead of what the function should return. Here are the basic steps I did and a screenshot of what I’m seeing when I visit the page.

These steps are identical to the repro from one of the now-examples issues: https://github.com/zeit/now-examples/issues/493

now init create-react-app-functions cra-fun
cd cra-fun
npm i
now dev
now-dev-no-api

I’ve tried the above in a powershell terminal and also in an ubuntu WSL terminal running the same versions of node/yarn/now and I get the same behaviour. Does using nvm/nvm-windows have something to do with it? I’ve not had any other kind of issues using them.

I’ll note that if I deploy my projects using now the serverless functions on the /api routes work just fine. So it seems to just be something with now dev (at least for my environment) and not a config issue or anything with the individual projects.

I’m not sure what else to try and I didn’t see anything in the other issues here or in the now-examples repo that got things working for me. Please let me know if there’s something in particular I should try or any other info I can provide to help investigate.

In case it helps, here is a screenshot of my terminal after running now dev -d

now-dev-debug-log

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
TooTallNatecommented, Oct 11, 2019

Right, so that’s actually exactly the issue. The now dev server is the one listening on port 3000. The CRA server (which now dev boots up for the React frontend) is the randomized port.

If you visit http://localhost:3000 instead, you should get the expected output from the /api/date endpoint.

The issue here is basically that it’s confusing that two URLs are printed, so I don’t blame you for mixing up which is the correct one. We will have to think of a solution to make that less confusing.

0reactions
brentkellercommented, Oct 11, 2019

Thanks for the explanation, it does work when I hit the address on port 3000. Makes me feel kinda dumb for not trying them both. I guess I just got too used to the CRA server being on 3000 and I figured the now server would be last since I saw something about waiting for ports in #2856 . I haven’t looked into how the builders work but I wonder if there’s a way to prefix or annotate the output of each builder. That might help clarify where messages come from. I can imagine it gets even more tricky with multiple builders.

Anyway, this gets me past my issue so thank you for the help on that. Seems like there isn’t a real issue here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serverless Functions in Computing - Microsoft Azure
Execute event-driven serverless code functions with an end-to-end development experience. Try Azure Functions free. Product overview; Features; Security ...
Read more >
Setting Up Serverless Framework With AWS
Note: If you don't already have Node on your machine, install it first. If you don't want to install Node or NPM, you...
Read more >
Serverless Functions – Vercel Docs
You can use Environment Variables inside your Serverless Functions, both locally with vercel dev as well as deployed to Preview and Production environments....
Read more >
Tutorial: Deploying a Hello World application
This means that you have not set up AWS credentials to enable the AWS SAM CLI to make AWS service calls. To fix...
Read more >
A crash course on Serverless with Node.js - Medium
Now you're ready to create a new service. What's a service you ask? View it like a project. But not really. It's where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found