We provide some simple examples on how to set up a mock API so you can work in your localhost.
Step 1: Download resource
Download resource inside the README.md or MOCK_API.md.
next-ts
├── README.md
├── ...Minimal_Typescript
├── MOCK_API.md
├── ...Step 2: Start local server
minimal-api-dev folder.http://localhost:7272.DEV_API: "http://localhost:7272","dev": "next dev -p 7272",
"start": "next start -p 7272",yarn install
yarn devStep 3:
Update .env in your current project:
next.jsvite.jsstarter-next-tsstarter-vite-tsVITE_SERVER_URL=http://localhost:7272
VITE_ASSET_URL=http://localhost:7272Support for Vercel and Cloudflare servers.
Step 1:
minimal-api-dev to your github.Step 2:
In next.config.mjs of minimal-api-dev.
const nextConfig = {
reactStrictMode: true,
env: {
DEV_API: 'http://localhost:7272',
PRODUCTION_API: 'https://your-domain-api.vercel.app',
},
};
export default nextConfig;Step 3:
Update .env in your current project:
next.jsvite.jsstarter-next-tsstarter-vite-tsVITE_SERVER_URL=https://your-domain-api.vercel.app
VITE_ASSET_URL=https://your-domain-api.vercel.app