首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hunchentoot启用CORS

Hunchentoot启用CORS
EN

Stack Overflow用户
提问于 2019-12-04 22:23:44
回答 1查看 190关注 0票数 5

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

代码语言:javascript
复制
  (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))))

但还是不能工作,我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2019-12-13 03:47:36

下面的方法对我很有效:

代码语言:javascript
复制
(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")
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59178214

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档