Using Next Js with Node Js backend on the same project on Vercel
Unanswered
Hällefors Elkhound posted this in #help-forum
Hällefors ElkhoundOP
As per the title, I've created the frontend in Next Js and backend in Node Js. I do not want to upload it separately on Vercel, but rather as just 1 singular project. I've made two directories in the root directory; one for frontend and one for backend. After setting up vercel.json for the builds and routes, the deployed website just shows the default Next Js front page. Is it even possible to accomplish what I'm trying to do?
3 Replies
@Hällefors Elkhound As per the title, I've created the frontend in Next Js and backend in Node Js. I do not want to upload it separately on Vercel, but rather as just 1 singular project. I've made two directories in the root directory; one for frontend and one for backend. After setting up vercel.json for the builds and routes, the deployed website just shows the default Next Js front page. Is it even possible to accomplish what I'm trying to do?
nextjs is made for backend & frontend. So there should be no problem with doing that. Can you please share more details: code, file structure, ...
@Hällefors Elkhound As per the title, I've created the frontend in Next Js and backend in Node Js. I do not want to upload it separately on Vercel, but rather as just 1 singular project. I've made two directories in the root directory; one for frontend and one for backend. After setting up vercel.json for the builds and routes, the deployed website just shows the default Next Js front page. Is it even possible to accomplish what I'm trying to do?
Prairie yellowjacket
Hey, You doesn't directily host nodejs in vercel. Because, vercel serverless platform and you doesn't host server file things, alternatively you try this,
{
"version": 2,
"builds": [
{
"src": "frontend/package.json",
"use": "@vercel/next"
},
{
"src": "backend/api/*.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "frontend/$1"
},
{
"src": "/api/(.*)",
"dest": "backend/api/$1"
}
]
}@Hällefors Elkhound solved?