mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 14:10: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>()
|
||||
.get(async(req, res) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', process.env.KOREANBOTS_URL)
|
||||
const { imageRateLimit } = await import('@utils/Query')
|
||||
const { id: param, size=256 } = req.query
|
||||
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 (!http.STATUS_CODES[code]) throw new Error('Invalid http 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 })
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user