gpt4 book ai didi

common-lisp - Hunchentoot 启用 CORS

转载 作者:行者123 更新时间:2023-12-01 04:25:00 25 4
gpt4 key购买 nike

我在 hunchentoot 上启用 CORS 时遇到了一些问题:

  (hunchentoot:define-easy-handler (one-api :uri *one-endpoint*) () 
(when (boundp '*acceptor*)
(setf (hunchentoot:header-out "Access-Control-Allow-Origin") "*")
(setf (hunchentoot:header-out "Accept") "*/*")
(setf (hunchentoot:header-out "Access-Control-Allow-Headers") "Content-Type, Accept, Origin")
(setf (hunchentoot:header-out "Access-Control-Allow-Methods") "POST, GET, OPTIONS, PUT, DELETE")
(setf (hunchentoot:header-out "Access-Control-Allow-Origin") "*")
(setf (hunchentoot:content-type*) "text/html"))
(let* ((raw-data (hunchentoot:raw-post-data :force-text t)))
(funcall callback raw-data))))

但仍然无法正常工作,我做错了什么?

最佳答案

以下对我有用:

(setf (header-out "Access-Control-Allow-Origin") "*")
(setf (header-out "Access-Control-Allow-Methods") "POST,GET,OPTIONS,DELETE,PUT")
(setf (header-out "Access-Control-Max-Age") 1000)
(setf (header-out "Access-Control-Allow-Headers") "x-requested-with, Content-Encoding, Content-Type, origin, authorization, accept, client-security-token")
(setf (header-out "Content-Type") "text/json")

关于common-lisp - Hunchentoot 启用 CORS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59178214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com