Skip to content

Next.js app with Python serverless functions #4023

Discussion options

You must be logged in to vote

Hello,

Next.js allows API routes in the framework itself. For that reason, it is not possible to use other languages than Node when using /pages/api. One thing that you can try is to defer the API-side to Now itself, but be aware that you may lose a few functionalities:

  • Create api/.
  • Create api/index.py.
  • Make sure you are not using pages/api/, otherwise, you can have a few conflicts in routes.
  • Redeploy.

Let me also clarify a few things:

I can get the API endpoint to work by adding { "src": "pages/api/*.py", "use": "@now/python" } to the "builds" property of now.json but that causes pages/index.js to not show up in the rendered app. I only get a directory view which I can follow to the A…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@STRRL
Comment options

Answer selected by mcsdevv
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants