I’m using Ably as provider for my Express application. Vercel itself suggests to use Ably, among others, to manage websockets.
The issue is that once my deployed application successfully connects to Ably, it can no longer publish or subscribe to channels. It appears that something is blocking the communication in any direction. Everything works perfectly on localhost, so I suspect the problem is related to Vercel’s configuration.
Here the dependencies used in the project:
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/mongoose": "^5.11.97",
"@types/uuid": "^9.0.8",
"dotenv": "^16.4.5",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.0.0",
"jest": "^29.7.0",
"nodemon": "^3.1.0",
"pre-commit": "^1.2.2",
"prettier": "^3.2.5",
"ts-jest": "^29.1.4",
"ts-loader": "^9.5.1",
"tsx": "^4.9.3",
"typescript": "^5.4.5",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node": "^20.11.22",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.1.0",
"ably": "^2.0.4",
"cors": "^2.8.5",
"express": "^4.19.2",
"fp-ts": "^2.16.6",
"io-ts": "^2.2.21",
"mongodb": "^6.6.0",
"mongoose": "^8.3.3",
"random-words": "^2.0.1",
"uuid": "^9.0.1"
}
The vercel.json
is:
{
"version": 2,
"builds": [
{
"src": "dist/bundle.js",
"use": "@vercel/node",
"config": { "includeFiles": ["dist/**"] }
}
],
"routes": [
{
"src": "/(.*)",
"dest": "dist/bundle.js",
"methods": ["GET", "POST", "PATCH", "DELETE", "OPTIONS"],
"headers": {
"Access-Control-Allow-Origin": "*"
}
}
]
}
Any idea on what it could cause this?