3987baa11b
* Improve typing of client CORS helper * Take node-fetch as a dependency * Add explicit Firebase region into config * Add new Vercel proxy API routes that talk to backend * Call Vercel proxy routes from `api-call` module * Tweak import to try to get Vercel happy * Tidy up a tiny bit
21 lines
534 B
TypeScript
21 lines
534 B
TypeScript
import Cors from 'cors'
|
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
export function applyCorsHeaders(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse,
|
|
params: Cors.CorsOptions
|
|
) {
|
|
// This cors module is made as express.js middleware, so it's easier to promisify it for ourselves.
|
|
return new Promise((resolve, reject) => {
|
|
Cors(params)(req, res, (result) => {
|
|
if (result instanceof Error) {
|
|
return reject(result)
|
|
}
|
|
return resolve(result)
|
|
})
|
|
})
|
|
}
|
|
|
|
export const CORS_UNRESTRICTED = {}
|