I’ve deployed a full stack app with next.js for frontend and express.js for the backend using a monorepo.
When I click on any link on the page, the whole page reloads although I am using next/link
This is vercel.json
at the root level
{
"builds": [
{
"src": "frontend/package.json",
"use": "@vercel/next"
},
{
"src": "backend/index.js",
"use": "@vercel/node",
"config": {
"buildCommand": "npm run build"
}
}
],
"routes": [
{ "src": "/api/(.*)", "dest": "/backend/index.js" },
{ "src": "/(.*)", "dest": "/frontend/$1" }
]
}
This is package.json at the root level
{
"name": "my-estate",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "concurrently \"npm run dev --prefix frontend\" \"npm run dev --prefix backend\""
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"concurrently": "^9.1.2"
}
}
https://my-estate-app.vercel.app/
next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: ['res.cloudinary.com', 'plus.unsplash.com'],
// loader: 'cloudinary',
// path: 'https://res.cloudinary.com/my-username/image/upload',
remotePatterns: [
{
protocol: 'https',
hostname: 'images.pexels.com',
pathname: '**',
},
],
},
};
export default nextConfig;