Quantcast
Channel: User Mat Longinow - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Vercel + Express: Can't hit any endpoint but root

$
0
0

I have an express app set up and running fine locally, but on Vercel it will deploy successfully, but only the Hello World! of the / will show, while all other endpoints will 500 error on me.

So for example:

index.js

// This works on my Vercelindex.get('/', (req, res) => {   res.send('Hello World!')})// This would notindex.post('/someEndpoint', (req, res) =>  {   some code here....})

This is my vercel.json (yes, I have read the Vercel Express documentation, it is unhelpful)

{"version": 2,"builds": [    {"src": "./index.js","use": "@vercel/node"    }  ],"rewrites": [    {"source": "/(.*)","destination": "/"    }  ]}

I have also added this to my index.js:

const corsOptions = {"origin": "*","methods": "GET, HEAD, PUT, PATCH, POST, DELETE",    // other options}index.use(cors(corsOptions));

I have spent hours on this now googling every nook and cranny I can find, but no go. Any help would be appreciated!


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images