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() { headers() {
return [ return [
{
source: '/api/oembed',
headers: [
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Access-Control-Allow-Headers', value: '*' },
],
},
{ {
source: '/', source: '/',
headers: [{ key: 'X-Frame-Options', value: 'SAMEORIGIN' }], headers: [{ key: 'X-Frame-Options', value: 'SAMEORIGIN' }],

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

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