Fix Vercel ES module import issues
- Change JSON import to use require() to avoid module loading issues - Add api/tsconfig.json with CommonJS module configuration - Update Vercel Node.js runtime to @vercel/node@3.2.0 - Add buildCommand to vercel.json for proper compilation - Fix 'Cannot use import statement outside a module' error
This commit is contained in:
parent
6f40a5058d
commit
9243f6ff4e
3 changed files with 28 additions and 3 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
import { Pool } from 'pg';
|
import { Pool } from 'pg';
|
||||||
import cardsData from '../src/data/cards.json';
|
|
||||||
|
// Use require for JSON import to avoid module issues
|
||||||
|
const cardsData = require('../src/data/cards.json');
|
||||||
|
|
||||||
// Create PostgreSQL connection pool
|
// Create PostgreSQL connection pool
|
||||||
const pool = new Pool({
|
const pool = new Pool({
|
||||||
|
|
|
||||||
22
api/tsconfig.json
Normal file
22
api/tsconfig.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "CommonJS",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"declaration": false,
|
||||||
|
"outDir": "./dist"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -52,7 +52,8 @@
|
||||||
],
|
],
|
||||||
"functions": {
|
"functions": {
|
||||||
"api/**/*.ts": {
|
"api/**/*.ts": {
|
||||||
"runtime": "@vercel/node@3.0.7"
|
"runtime": "@vercel/node@3.2.0"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"buildCommand": "npm run build"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue