mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 14:30:22 +00:00
feat: added CORS
This commit is contained in:
parent
4b7deb8e19
commit
61c302f7ec
@ -9,6 +9,7 @@ import { ImageOptionsSchema } from '@utils/Yup'
|
|||||||
|
|
||||||
const Avatar = nc<ApiRequest, NextApiResponse>()
|
const Avatar = nc<ApiRequest, NextApiResponse>()
|
||||||
.get(async(req, res) => {
|
.get(async(req, res) => {
|
||||||
|
res.setHeader('Access-Control-Allow-Origin', process.env.KOREANBOTS_URL)
|
||||||
const { imageRateLimit } = await import('@utils/Query')
|
const { imageRateLimit } = await import('@utils/Query')
|
||||||
const { id: param, size=256 } = req.query
|
const { id: param, size=256 } = req.query
|
||||||
const rate = ratelimit.image(req.socket.remoteAddress)
|
const rate = ratelimit.image(req.socket.remoteAddress)
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export default function ResponseWrapper<T=unknown>(
|
|||||||
if (!code) throw new Error('`code` is required.')
|
if (!code) throw new Error('`code` is required.')
|
||||||
if (!http.STATUS_CODES[code]) throw new Error('Invalid http code.')
|
if (!http.STATUS_CODES[code]) throw new Error('Invalid http code.')
|
||||||
res.statusCode = code
|
res.statusCode = code
|
||||||
|
res.setHeader('Access-Control-Allow-Origin', process.env.KOREANBOTS_URL)
|
||||||
res.json({ code, message: message || http.STATUS_CODES[code], data, errors, version })
|
res.json({ code, message: message || http.STATUS_CODES[code], data, errors, version })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user