pig*_*ack 6 common-lisp hunchentoot
我在 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))))
Run Code Online (Sandbox Code Playgroud)
但还是不行,是我哪里做错了吗?
以下对我有用:
(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")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
346 次 |
| 最近记录: |