If your payment success URL is not functioning correctly on Vercel, follow these steps to resolve the issue:
Ensure your project is organized as follows:
/project-root
├── public (directory for HTML, CSS, and JS files)
├── src
│ ├── index.ts (or app.ts, server.ts, etc.)
│ ├── app
├── dist (compiled JavaScript files)
├── node_modules
├── package.json
├── tsconfig.json
└── vercel.json
In your Express app (app.ts), configure it to serve static files from the public
directory:
import express from 'express';
import path from 'path';
const app = express();
// Serve static files from the "public" directory
app.use(express.static(path.join(__dirname, 'public')));
Make sure file paths for your HTML templates are accurate. For example:
import { readFileSync } from 'fs';
import { join } from 'path';
const filePath = join(__dirname, '../../../../public/confirmation.html'); // update your html file path
let template = readFileSync(filePath, 'utf-8');
template = template.replace('{{message}}', message);
Deploy your application with the Vercel CLI:
npm run build
vercel
vercel --prod
By following these steps, you should be able to resolve issues related to the payment success URL on Vercel.