VERCEL_DEPLOYMENT.md•3.3 kB
# Vercel Deployment Guide
This project is configured to deploy on Vercel. Follow these steps to deploy:
## Prerequisites
1. A Vercel account (sign up at https://vercel.com)
2. Your Airtable Personal Access Token
## Deployment Steps
### 1. Push to GitHub
Make sure your code is pushed to a GitHub repository.
### 2. Import Project to Vercel
1. Go to https://vercel.com/new
2. Import your GitHub repository
3. Vercel will auto-detect the project settings
### 3. Configure Environment Variables
In Vercel project settings, add the following environment variable:
- **Name**: `AIRTABLE_API_KEY`
- **Value**: Your Airtable Personal Access Token (e.g., `pat123.abc123...`)
- **Environment**: Production, Preview, Development (select all)
To get your API key:
1. Visit https://airtable.com/create/tokens/new
2. Create a token with scopes: `schema.bases:read`, `data.records:read`
3. Copy the token
### 4. Build Settings
Vercel will automatically detect:
- **Framework Preset**: Other
- **Build Command**: `npm run build` (from vercel.json)
- **Output Directory**: Not needed (handled by Express)
- **Install Command**: `npm install`
### 5. Deploy
Click "Deploy" and Vercel will:
1. Install dependencies
2. Run `npm run build` to compile TypeScript
3. Deploy the Express server as serverless functions
4. Serve static files from `public/` directory
## Project Structure for Vercel
```
├── api/
│ └── index.js # Vercel serverless function entry point
├── dist/ # Compiled TypeScript (built during deployment)
├── public/ # Static files (HTML, CSS, JS)
├── src/ # TypeScript source files
├── server.js # Local development server
├── vercel.json # Vercel configuration
└── package.json # Dependencies and scripts
```
## How It Works
1. **Build Process**: `npm run build` compiles TypeScript to JavaScript in `dist/`
2. **Serverless Function**: `api/index.js` exports the Express app
3. **Routing**: All requests are routed to `/api/index` which handles:
- Static file serving from `public/`
- API endpoints (`/api/bases`, `/api/bases/:baseId/tables`, etc.)
## Environment Variables
Required:
- `AIRTABLE_API_KEY`: Your Airtable Personal Access Token
Optional:
- `NODE_ENV`: Automatically set to "production" by Vercel
- `PORT`: Automatically set by Vercel (not needed)
## Local Development
The project still works locally:
```bash
npm run build
npm run web
```
The `server.js` file detects if it's running on Vercel and only starts the HTTP server locally.
## Troubleshooting
### Build Fails
- Check that TypeScript compiles: `npm run build`
- Ensure all dependencies are in `package.json`
### API Returns Errors
- Verify `AIRTABLE_API_KEY` is set in Vercel environment variables
- Check Vercel function logs for detailed error messages
### Static Files Not Loading
- Ensure `public/` directory exists and contains `index.html`
- Check that `vercel.json` rewrites are configured correctly
## Notes
- The Express server runs as a serverless function on Vercel
- Static files are served through Express, not Vercel's static hosting
- All API routes are handled by the Express app
- The build process compiles TypeScript before deployment