Hello,
Since a few days we have issues with relative url's in vercels serverless functions. This problem only happpens on the vercel environment. The setup works locally with vercel dev.
Explanation:
I have serverless function X.js
FILE: /api/x.js
There is some code, in a specific condition it makes a call to another serverless function called y.js.
const { data: testData } = await axios.post('/api/y')
FILE: /api/y.js
Both files exists, and it works locally, but since a few days it doesn't work on the vercel environment.
When I replace the url to a full url, then it works again:
const { data: testData } = await axios.post('https://some-vercel-domain.com/api/y')
Error log in Vercel:
Uncaught Exception: ReferenceError: DOMException is not defined at Dt (/opt/rust/nodejs.js:8:12511) at ClientRequest.<anonymous> (/opt/rust/nodejs.js:8:10713) at Object.onceWrapper (node:events:628:26) at ClientRequest.emit (node:events:525:35) at ClientRequest.emit (node:domain:489:12) at Socket.socketErrorListener (node:_http_client:494:9) at Socket.emit (node:events:513:28) at Socket.emit (node:domain:489:12) at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3)Node.js process exited with exit status: 129. The logs above can help with debugging the issue.