久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" 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>
                            主站蜘蛛池模板: 亚洲免费一区 | 国产精品久久久久久久久久免费 | 久久久日韩精品一区二区三区 | 涩涩视频在线观看 | 日韩精品一二三区 | 亚洲国产精品久久 | 国产精品久久久亚洲 | 97av在线| 黄色一级片在线播放 | 国产欧美精品一区二区色综合朱莉 | 一区二区免费高清视频 | 欧美一级欧美三级在线观看 | 视频一区二区在线观看 | 亚洲精品区 | 国产免费高清 | 五月激情婷婷网 | 天天综合久久 | 国产精品亚洲视频 | 99精品国产一区二区三区 | 成人精品一区亚洲午夜久久久 | 亚洲精品乱码久久久久久9色 | 91精品国产91久久久久久 | 亚洲高清免费 | 色综合久久久 | 三区四区在线观看 | 亚洲网站在线观看 | 亚洲激精日韩激精欧美精品 | 久久人人爽人人爽人人片av免费 | 一区二区三区亚洲 | 欧美一区二区三区在线播放 | 久久国产欧美日韩精品 | 久久精品免费 | 色片在线观看 | 免费观看日韩精品 | 久国产 | 一区二区三区四区视频 | 另类在线 | 国产在线精品一区二区三区 | 精品久久久久久久久久久院品网 | 自拍偷拍亚洲视频 | 精品一区av|