pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

        <legend id='b15P4'><style id='b15P4'><dir id='b15P4'><q id='b15P4'></q></dir></style></legend>

      1. <tfoot id='b15P4'></tfoot>

        <small id='b15P4'></small><noframes id='b15P4'>

        • <bdo id='b15P4'></bdo><ul id='b15P4'></ul>
        <i id='b15P4'><tr id='b15P4'><dt id='b15P4'><q id='b15P4'><span id='b15P4'><b id='b15P4'><form id='b15P4'><ins id='b15P4'></ins><ul id='b15P4'></ul><sub id='b15P4'></sub></form><legend id='b15P4'></legend><bdo id='b15P4'><pre id='b15P4'><center id='b15P4'></center></pre></bdo></b><th id='b15P4'></th></span></q></dt></tr></i><div class="qeqy8ac" id='b15P4'><tfoot id='b15P4'></tfoot><dl id='b15P4'><fieldset id='b15P4'></fieldset></dl></div>

      2. hapi.js Cors Pre-flight 不返回 Access-Control-Allow-Origin

        hapi.js Cors Pre-flight not returning Access-Control-Allow-Origin header(hapi.js Cors Pre-flight 不返回 Access-Control-Allow-Origin 標頭)
          • <legend id='vcpyL'><style id='vcpyL'><dir id='vcpyL'><q id='vcpyL'></q></dir></style></legend>
              <tbody id='vcpyL'></tbody>
                  <bdo id='vcpyL'></bdo><ul id='vcpyL'></ul>

                  <tfoot id='vcpyL'></tfoot>

                  <small id='vcpyL'></small><noframes id='vcpyL'>

                  <i id='vcpyL'><tr id='vcpyL'><dt id='vcpyL'><q id='vcpyL'><span id='vcpyL'><b id='vcpyL'><form id='vcpyL'><ins id='vcpyL'></ins><ul id='vcpyL'></ul><sub id='vcpyL'></sub></form><legend id='vcpyL'></legend><bdo id='vcpyL'><pre id='vcpyL'><center id='vcpyL'></center></pre></bdo></b><th id='vcpyL'></th></span></q></dt></tr></i><div class="wskg6ui" id='vcpyL'><tfoot id='vcpyL'></tfoot><dl id='vcpyL'><fieldset id='vcpyL'></fieldset></dl></div>

                  本文介紹了hapi.js Cors Pre-flight 不返回 Access-Control-Allow-Origin 標頭的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個使用 (Dropzone js) 上傳的 ajax 文件.它將文件發送到我的 hapi 服務器.我意識到瀏覽器發送了一個 PREFLIGHT OPTIONS METHOD.但我的 hapi 服務器似乎沒有發送正確的響應標頭,所以我在 chrome 上遇到錯誤.這是我在 chrome 上遇到的錯誤

                  I have an ajax file upload using (Dropzone js). which sends a file to my hapi server. I realised the browser sends a PREFLIGHT OPTIONS METHOD. but my hapi server seems not to send the right response headers so i am getting errors on chrome. here is the error i get on chrome

                  XMLHttpRequest cannot load http://localhost:3000/uploadbookimg. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
                  

                  這是 hapi js 路由處理程序

                  this is the hapi js route handler

                  server.route({
                          path: '/uploadbookimg',
                          method: 'POST',
                          config: {
                              cors : true,
                              payload: {
                                  output: 'stream',
                                  parse: true,
                                  allow: 'multipart/form-data'
                              },
                          handler: require('./books/webbookimgupload'),
                          }
                      });
                  

                  據我了解,hapi js 應該從 Pre-fight (OPTIONS) 請求中發送所有 cors 標頭.不明白為什么不是

                  In my understanding hapi js should send all cors headers from the Pre-fight (OPTIONS) request. Cant understand why its is not

                  來自 chrome 的網絡請求/響應

                  Network request /response from chrome

                  **General**
                  Request Method:OPTIONS
                  Status Code:200 OK
                  Remote Address:127.0.0.1:3000
                  
                  **Response Headers**
                  view parsed
                  HTTP/1.1 200 OK
                  content-type: application/json; charset=utf-8
                  cache-control: no-cache
                  vary: accept-encoding
                  Date: Wed, 27 Apr 2016 07:25:33 GMT
                  Connection: keep-alive
                  Transfer-Encoding: chunked
                  
                  **Request Headers**
                  view parsed
                  OPTIONS /uploadbookimg HTTP/1.1
                  Host: localhost:3000
                  Connection: keep-alive
                  Pragma: no-cache
                  Cache-Control: no-cache
                  Access-Control-Request-Method: POST
                  Origin: http://localhost:4200
                  User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36
                  Access-Control-Request-Headers: accept, cache-control, content-type
                  Accept: */*
                  Referer: http://localhost:4200/books/upload
                  Accept-Encoding: gzip, deflate, sdch
                  Accept-Language: en-US,en;q=0.8
                  

                  提前致謝

                  推薦答案

                  hapi cors: true 是一個通配符規則,允許來自所有域的 CORS 請求,除了少數情況,包括有額外的hapi 的默認白名單之外的請求標頭:

                  The hapi cors: true is a wildcard rule that allows CORS requests from all domains except for a few cases including when there are additional request headers outside of hapi's default whitelist:

                  [accept"、authorization"、content-type"、if-none-match"、origin"]

                  請參閱 API 文檔中路由選項下的 cors 選項部分:

                  headers - 允許的標頭的字符串數組('Access-Control-Allow-Headers').默認為 ['Accept', 'Authorization', 'Content-Type', 'If-None-Match'].

                  headers - a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match'].

                  additionalHeaders - 附加標頭到標頭的字符串數組.使用它來保留默認標題.

                  additionalHeaders - a strings array of additional headers to headers. Use this to keep the default headers in place.

                  您的問題是 Dropzone 發送了幾個標題以及不在此列表中的文件上傳:

                  Your problem is that Dropzone sends a couple of headers along with the file upload that aren't in this list:

                  • x-requested-with(不在您上面的標題中,而是為我發送的)
                  • 緩存控制
                  • x-requested-with (not in your headers above but was sent for me)
                  • cache-control

                  您有兩個選項可以讓事情正常運行,您需要在服務器或客戶端上進行更改:

                  You have two options to get things working, you need to change something on either the server or the client:

                  server.route({
                      config: {
                          cors: {
                              origin: ['*'],
                              additionalHeaders: ['cache-control', 'x-requested-with']
                          }
                      },
                      method: 'POST',
                      path: '/upload',
                      handler: function (request, reply) {
                  
                          ...
                      }
                  });
                  

                  選項 2 - 告訴 dropzone 不要發送那些額外的標頭

                  通過他們的配置尚不可能,但有一個待定的 PR 允許它:https://github.com/enyo/dropzone/pull/685

                  這篇關于hapi.js Cors Pre-flight 不返回 Access-Control-Allow-Origin 標頭的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                • <i id='ZpST3'><tr id='ZpST3'><dt id='ZpST3'><q id='ZpST3'><span id='ZpST3'><b id='ZpST3'><form id='ZpST3'><ins id='ZpST3'></ins><ul id='ZpST3'></ul><sub id='ZpST3'></sub></form><legend id='ZpST3'></legend><bdo id='ZpST3'><pre id='ZpST3'><center id='ZpST3'></center></pre></bdo></b><th id='ZpST3'></th></span></q></dt></tr></i><div class="c8iuasg" id='ZpST3'><tfoot id='ZpST3'></tfoot><dl id='ZpST3'><fieldset id='ZpST3'></fieldset></dl></div>
                      <tfoot id='ZpST3'></tfoot>
                        <bdo id='ZpST3'></bdo><ul id='ZpST3'></ul>
                          <tbody id='ZpST3'></tbody>

                            <small id='ZpST3'></small><noframes id='ZpST3'>

                            <legend id='ZpST3'><style id='ZpST3'><dir id='ZpST3'><q id='ZpST3'></q></dir></style></legend>
                            主站蜘蛛池模板: 识禅_对禅的了解,从这里开始| POM塑料_PBT材料「进口」聚甲醛POM杜邦原料、加纤PBT塑料报价格找利隆塑料 | ?水马注水围挡_塑料注水围挡_防撞桶-常州瑞轩水马注水围挡有限公司 | 原色会计-合肥注册公司_合肥代理记账公司_营业执照代办 | 最新范文网_实用的精品范文美文网 | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | 气动机械手-搬运机械手-气动助力机械手-山东精瑞自动化设备有限公司 | 工业车间焊接-整体|集中除尘设备-激光|等离子切割机配套除尘-粉尘烟尘净化治理厂家-山东美蓝环保科技有限公司 | 浴室柜-浴室镜厂家-YINAISI · 意大利设计师品牌 | 咿耐斯 |-浙江台州市丰源卫浴有限公司 | 武汉高低温试验机-现货恒温恒湿试验箱-高低温湿热交变箱价格-湖北高天试验设备 | 清管器,管道清管器,聚氨酯发泡球,清管球 - 承德嘉拓设备 | 培训中心-海南香蕉蛋糕加盟店技术翰香原中心官网总部 | 焊接烟尘净化器__焊烟除尘设备_打磨工作台_喷漆废气治理设备 -催化燃烧设备 _天津路博蓝天环保科技有限公司 | LNG鹤管_内浮盘价格,上装鹤管,装车撬厂家-连云港赛威特机械 | UV固化机_UVLED光固化机_UV干燥机生产厂家-上海冠顶公司专业生产UV固化机设备 | 上海律师咨询_上海法律在线咨询免费_找对口律师上策法网-策法网 广东高华家具-公寓床|学生宿舍双层铁床厂家【质保十年】 | 手持气象站_便携式气象站_农业气象站_负氧离子监测站-山东万象环境 | 冷却塔厂家_冷却塔维修_冷却塔改造_凉水塔配件填料公司- 广东康明节能空调有限公司 | 密集架-手摇-智能-移动-价格_内蒙古档案密集架生产厂家 | 排烟防火阀-消防排烟风机-正压送风口-厂家-价格-哪家好-德州鑫港旺通风设备有限公司 | 预制舱-电力集装箱预制舱-模块化预制舱生产厂家-腾达电器设备 | SDI车窗夹力测试仪-KEMKRAFT方向盘测试仪-上海爱泽工业设备有限公司 | 橡胶粉碎机_橡胶磨粉机_轮胎粉碎机_轮胎磨粉机-河南鼎聚重工机械制造有限公司 | 上海公司注册-代理记账-招投标审计-上海昆仑扇财税咨询有限公司 上海冠顶工业设备有限公司-隧道炉,烘箱,UV固化机,涂装设备,高温炉,工业机器人生产厂家 | 线材成型机,线材折弯机,线材成型机厂家,贝朗自动化设备有限公司1 | 回转支承-转盘轴承-回转驱动生产厂家-洛阳隆达轴承有限公司 | 企业彩铃制作_移动、联通、电信集团彩铃上传开通_彩铃定制_商务彩铃管理平台-集团彩铃网 | elisa试剂盒-PCR试剂盒「上海谷研实业有限公司」 | 亿立分板机_曲线_锯片式_走刀_在线式全自动_铣刀_在线V槽分板机-杭州亿协智能装备有限公司 | 火锅加盟_四川成都火锅店加盟_中国火锅连锁品牌十强_朝天门火锅【官网】 | 微型气泵-真空-蠕动-水泵-厂家-深圳市品亚科技有限公司 | DWS物流设备_扫码称重量方一体机_快递包裹分拣机_广东高臻智能装备有限公司 | 六维力传感器_三维力传感器_二维力传感器-南京神源生智能科技有限公司 | 退火炉,燃气退火炉,燃气热处理炉生产厂家-丹阳市丰泰工业炉有限公司 | Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | 酒店品牌设计-酒店vi设计-酒店标识设计【国际级】VI策划公司 | 水成膜泡沫灭火剂_氟蛋白泡沫液_河南新乡骏华消防科技厂家 | ?水马注水围挡_塑料注水围挡_防撞桶-常州瑞轩水马注水围挡有限公司 | 选矿设备-新型重选设备-金属矿尾矿重选-青州冠诚重工机械有限公司 | 原子吸收设备-国产分光光度计-光谱分光光度计-上海光谱仪器有限公司 | 常州减速机_减速机厂家_常州市减速机厂有限公司 |