Add OPTIONS endpoint to allow the content-type header for the upload endpoint (#869)
* Add OPTIONS endpoint to allow the content-type header exec git commit --amend --no-edit -S * Remove useless header "Access-Control-Headers" and add cache Signed-off-by: Arnaud <arnaud@status.im> --------- Signed-off-by: Arnaud <arnaud@status.im> Co-authored-by: Giuliano Mega <giuliano.mega@gmail.com>
This commit is contained in:
parent
2771ca6319
commit
bb9a5fbe92
|
@ -110,6 +110,20 @@ proc retrieveCid(
|
||||||
proc initDataApi(node: CodexNodeRef, repoStore: RepoStore, router: var RestRouter) =
|
proc initDataApi(node: CodexNodeRef, repoStore: RepoStore, router: var RestRouter) =
|
||||||
let allowedOrigin = router.allowedOrigin # prevents capture inside of api defintion
|
let allowedOrigin = router.allowedOrigin # prevents capture inside of api defintion
|
||||||
|
|
||||||
|
router.api(
|
||||||
|
MethodOptions,
|
||||||
|
"/api/codex/v1/data") do (
|
||||||
|
resp: HttpResponseRef) -> RestApiResponse:
|
||||||
|
|
||||||
|
if corsOrigin =? allowedOrigin:
|
||||||
|
resp.setHeader("Access-Control-Allow-Origin", corsOrigin)
|
||||||
|
resp.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS")
|
||||||
|
resp.setHeader("Access-Control-Allow-Headers", "content-type")
|
||||||
|
resp.setHeader("Access-Control-Max-Age", "86400")
|
||||||
|
|
||||||
|
resp.status = Http204
|
||||||
|
await resp.sendBody("")
|
||||||
|
|
||||||
router.rawApi(
|
router.rawApi(
|
||||||
MethodPost,
|
MethodPost,
|
||||||
"/api/codex/v1/data") do (
|
"/api/codex/v1/data") do (
|
||||||
|
|
Loading…
Reference in New Issue