Skip to content

Commit

Permalink
Create api with nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheeDouglasAM3 committed Jan 29, 2021
1 parent c2d84e3 commit 31723ba
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pages/api/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import db from '../../db.json'

export default function dbHandler(request, response) {
if (request.method === 'OPTIONS') {
response.status(200).end()
return
}

response.setHeader('Access-Control-Allow-Credentials', true)
response.setHeader('Access-Control-Allow-Origin', '*')
response.setHeader('Access-Control-Allow-Methods', 'GET,OPTIONS,PATCH,DELETE,POST,PUT')

response.json(db)
}

0 comments on commit 31723ba

Please sign in to comment.