Closed jacksonh closed 1 year ago
I think this would work:
import type { NextApiRequest, NextApiResponse } from 'next'
import { saveUrlMutation } from '../../lib/networking/mutations/saveUrlMutation'
// eslint-disable-next-line import/no-anonymous-default-export
export default async (
req: NextApiRequest,
res: NextApiResponse
): Promise<void> => {
let urlStr = req.query['url']
let url = new URL(urlStr as string)
let saveResult = await saveUrlMutation(url.toString())
if (saveResult?.jobId) {
res.redirect(`/sr/${saveResult?.jobId}`)
return
}
res.status(200).send('ok')
}
On vercel we should be able to easily support a call like: https://omnivore.app/api/save?url= this would just need a file in
packages/web/pages/api/save.ts
that makes the GQL call toSaveURL