I am following your doc to create a Python serverless function. It runs fine in production, but returns 404 in local (running vercel dev
). Why is that?
My project structure:
app
api
|- hello.py
requirements.txt
vercel.json
// requirements.txt
venmo-api==0.3.1
// vercel.json
{
"buildCommand": "npx convex deploy --cmd 'npm run build'",
"installCommand": "npm install --legacy-peer-deps",
"functions": {
"api/**": {
"excludeFiles": "{.next,*.cache,node_modules,public,app}/**"
}
}
}
// hello.py
from http.server import BaseHTTPRequestHandler
from venmo_api import Client
class handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write('Hello, world!'.encode('utf-8'))
return
system
(system)
December 10, 2024, 3:24am
2
There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.
Sometimes things don’t go as expected when deploying a website. If you see a 404 on your site, that means the page or resource couldn’t be found.
There are many possible causes, and the absence of something can be tricky debug if you don’t know where to look. Here are some things you can do to find the cause and fix it.
Debugging Tips
Check the error code
If you see a mostly white screen with 404: NOT_FOUND along with a Code and and ID then you can click the blue info box below the error deta…
A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0 .
amyegan
(Amy Egan)
December 13, 2024, 6:36pm
3
What is the Development Command for the project?
vercel dev
. I mentioned it in the question.
amyegan
(Amy Egan)
December 27, 2024, 6:48pm
5
Sorry, I wasn’t clear about what I meant. Projects can have a custom Development Command defined. Does your project have a development command specified?
No, here’s my package.json
:
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
...
}
My vercel.json
is in the original question.