move oembed api routes to pages/

main
Mike Fix 3 years ago
parent a691c33918
commit c70de8f116
No known key found for this signature in database
GPG Key ID: 1D85E862314CA79F

@ -35,6 +35,13 @@ module.exports = withBundleAnalyzer(
},
headers() {
return [
{
source: '/api/oembed',
headers: [
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Access-Control-Allow-Headers', value: '*' },
],
},
{
source: '/',
headers: [{ key: 'X-Frame-Options', value: 'SAMEORIGIN' }],

@ -23,14 +23,6 @@
"Service-Worker-Allowed": "/"
}
},
{
"src": "/api/oembed",
"dest": "api/oembed.js",
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*"
}
},
{
"src": "/api/image/?(?<id>[^/]*)",
"dest": "api/image/index.js?id=$id",

@ -2,7 +2,6 @@
* See oEmbed standard here: https://oembed.com/
*/
const url = require('url')
const { send } = require('micro')
const toIFrame = (url, width, height) =>
`<iframe
@ -46,13 +45,13 @@ module.exports = (req, res) => {
}`,
width,
height
)
),
}
return send(res, 200, obj)
return res.status(200).json(obj)
} catch (e) {
// eslint-disable-next-line
console.error(e)
return send(res, 500, e.message)
return res.status(500).send(e.message)
}
}
Loading…
Cancel
Save