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

<tfoot id='hMWnk'></tfoot>

        <i id='hMWnk'><tr id='hMWnk'><dt id='hMWnk'><q id='hMWnk'><span id='hMWnk'><b id='hMWnk'><form id='hMWnk'><ins id='hMWnk'></ins><ul id='hMWnk'></ul><sub id='hMWnk'></sub></form><legend id='hMWnk'></legend><bdo id='hMWnk'><pre id='hMWnk'><center id='hMWnk'></center></pre></bdo></b><th id='hMWnk'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hMWnk'><tfoot id='hMWnk'></tfoot><dl id='hMWnk'><fieldset id='hMWnk'></fieldset></dl></div>
        <legend id='hMWnk'><style id='hMWnk'><dir id='hMWnk'><q id='hMWnk'></q></dir></style></legend>
          <bdo id='hMWnk'></bdo><ul id='hMWnk'></ul>
      1. <small id='hMWnk'></small><noframes id='hMWnk'>

        當使用 mode: no-cors 請求時,瀏覽器沒有添加我在

        When using mode: no-cors for a request, browser isn’t adding request header I’ve set in my frontend code(當使用 mode: no-cors 請求時,瀏覽器沒有添加我在前端代碼中設置的請求標頭) - IT屋-程序員軟件開發技術

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

              <tfoot id='68K1Y'></tfoot>

              <legend id='68K1Y'><style id='68K1Y'><dir id='68K1Y'><q id='68K1Y'></q></dir></style></legend>
                <tbody id='68K1Y'></tbody>
                <bdo id='68K1Y'></bdo><ul id='68K1Y'></ul>
                1. 本文介紹了當使用 mode: no-cors 請求時,瀏覽器沒有添加我在前端代碼中設置的請求標頭的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在我的 React 應用程序中,我有以下 API POST 以允許用戶編輯他們的個人資料(名稱和圖像).

                  in my React app, I have the following API POST to allow the user to edit their profile (name and image).

                    static updateProfile(formData, user_id) {
                      const request = new Request(`http://localhost:4300/api/v1/profiles/${user_id}`, {
                        headers: new Headers({
                          'Authorization': getBearerToken()
                        }),
                        mode: 'no-cors',
                        method: "POST",
                        body: formData
                      });
                  
                      return fetch(request).then(response => {
                        return response.json();
                      }).catch(error => {
                        return error;
                      });
                    }
                  

                  上面的問題是帶有授權令牌的標頭沒有在 POST 中發送...

                  The problem with the above is the header with the Authorization token is not being sent in the POST...

                  如何在上面的 fetch 請求中獲取要發送的 Authorization 標頭?

                  How can I get the Authorization header to be send in the fetch request above?

                  僅供參考,對于非多部分表單,授權令牌已成功發送,如下所示:

                  FYI, for non-multipart forms, the authorization token is sent successfully like so:

                    static loadProfile(user_id) {
                      const request = new Request(`http://localhost:4300/api/v1/profiles/${user_id}`, {
                        headers: new Headers({
                          'Authorization': getBearerToken(),
                          'Accept'       : 'application/json',
                          'Content-Type' : 'application/json',
                        })
                      });
                  
                      return fetch(request).then(response => {
                        return response.json();
                      }).catch(error => {
                        return error;
                      });
                    }
                  

                  推薦答案

                  如果你設置了任何特殊的請求頭,你不能使用 no-cors 模式,因為使用它的效果之一request 是它告訴瀏覽器不允許您的前端 JavaScript 代碼設置除 CORS 安全列出的請求標頭.請參閱規范要求:

                  You can’t use no-cors mode if you set any special request headers, because one of effect of using it for a request is that it tells browsers to not allow your frontend JavaScript code to set any request headers other than CORS-safelisted request-headers. See the spec requirements:

                  要將 name/value 對附加到 Headers 對象 (headers),請運行以下步驟:

                  To append a name/value pair to a Headers object (headers), run these steps:

                  1. 否則,如果 guardrequest-no-cors";并且 name/value 不是 CORS-safelisted request-header,返回.
                  1. Otherwise, if guard is "request-no-cors" and name/value is not a CORS-safelisted request-header, return.

                  在該算法中,return 等同于在不將該標頭添加到 Headers 對象的情況下返回".

                  In that algorithm, return equates to "return without adding that header to the Headers object".

                  Authorization 不是 CORS-safelisted request-header,因此如果您使用 mode: 'no-cors' 請求,您的瀏覽器將不允許您設置.Content-Type: application/json 也一樣.

                  Authorization isn’t a CORS-safelisted request-header, so your browser won’t allow you to set if you use mode: 'no-cors'for a request. Same for Content-Type: application/json.

                  如果您嘗試使用 no-cors 模式的原因是為了避免在不使用時出現的其他問題,則解決方案是修復導致其他問題的根本原因.因為無論您試圖解決什么問題,mode: 'no-cors' 最終都不會成為解決方案.它只會產生不同的問題,比如你現在遇到的問題.

                  If the reason you’re trying to use no-cors mode is to avoid some other problem that occurs if you don’t use, the solution is to fix the underlying cause of that other problem. Because no matter what problem you might be trying to solve, mode: 'no-cors' isn’t going to turn out to be a solution in the end. It’s just going to create different problems like what you’re hitting now.

                  這篇關于當使用 mode: no-cors 請求時,瀏覽器沒有添加我在前端代碼中設置的請求標頭的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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() 的限制?)
                  <tfoot id='LmlhN'></tfoot>
                        <tbody id='LmlhN'></tbody>

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

                          • <small id='LmlhN'></small><noframes id='LmlhN'>

                          • <legend id='LmlhN'><style id='LmlhN'><dir id='LmlhN'><q id='LmlhN'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 亚洲韩国精品 | 国产一区二区三区视频 | 91精品国产91久久久久久 | 交专区videossex农村 | 欧美一级二级三级视频 | 亚洲精品久久久 | 超碰在线人人 | 久久综合狠狠综合久久综合88 | 日韩在线免费观看视频 | 无人区国产成人久久三区 | aⅴ色国产 欧美 | 亚洲看片网站 | 欧美a√| 欧美一区二区三区,视频 | 亚洲一区二区三区免费在线观看 | 农村妇女毛片精品久久久 | 一区在线观看 | 亚洲精品国产第一综合99久久 | 日p视频免费看 | 999精品在线观看 | 国产精品视频播放 | 成人在线视 | 91精品亚洲 | 日本精品一区二区三区视频 | 91久久国产综合久久91精品网站 | 日韩欧美一区二区三区四区 | 粉嫩一区二区三区性色av | 亚洲欧美在线一区 | 日韩av在线不卡 | 日韩欧美国产精品 | 国产精品久久久久久吹潮 | 自拍视频一区二区三区 | 一区二区三区视频在线 | 欧美国产精品一区二区 | 国产精品久久久久久吹潮 | 国产在线精品一区 | 日本在线播放一区二区 | 欧美精品一区二区三区在线播放 | 亚洲一区二区在线电影 | 日韩在线欧美 | 久久网亚洲 |