{"id":53655,"date":"2024-12-03T13:33:01","date_gmt":"2024-12-03T05:33:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53655\/"},"modified":"2024-12-03T13:33:01","modified_gmt":"2024-12-03T05:33:01","slug":"vue-%e9%85%8d%e7%bd%ae-proxy-%e4%be%9d%e7%84%b6%e8%b7%a8%e5%9f%9f%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53655\/","title":{"rendered":"Vue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Vue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f <\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300aVue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f \u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241203\/1733196648674e7b683a0b3.jpg\" class=\"aligncenter\" title=\"Vue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Vue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>Vue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><\/p>\n<p>\u4f60\u63d0\u4f9b\u7684\u914d\u7f6e\u4e2d\uff0cproxy \u4ee3\u7406\u4e86\u6307\u5b9a\u8def\u5f84\u4e0b\u7684\u8bf7\u6c42\u3002\u7136\u800c\uff0c\u4f60\u9047\u5230\u8de8\u57df\u95ee\u9898\uff0c\u9700\u8981\u8fdb\u4e00\u6b65\u5904\u7406\u3002<\/p>\n<p><strong>\u68c0\u67e5\u914d\u7f6e\u662f\u5426\u6b63\u786e<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u68c0\u67e5\u4f60\u7684\u914d\u7f6e\u662f\u5426\u6b63\u786e\u3002\u6839\u636e\u4f60\u63d0\u4f9b\u7684\u4ee3\u7801\uff0c\u4f60\u7684\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<pre>proxy: {\n  '\/hyjk_authorization': {\n    target: 'http:\/\/211.90.39.00:8089\/',\n    changOrigin: true,\n    pathRewrite: {\n      '^\/hyjk_authorization': ''\n    }\n  }\n}<\/pre>\n<p>\u770b\u4e0a\u53bb\u5e76\u6ca1\u6709\u95ee\u9898\uff0c\u4f46\u4e3a\u4e86\u4fdd\u9669\u8d77\u89c1\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4ee3\u7406\u5230\u4e00\u4e2a\u901a\u7528\u7684 CORS \u670d\u52a1\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>proxy: {\n  '\/hyjk_authorization': {\n    target: 'https:\/\/www.lilnong.top\/cors\/',\n    changOrigin: true,\n    pathRewrite: {\n      '^\/hyjk_authorization': ''\n    }\n  }\n}<\/pre>\n<p>\u5982\u679c\u901a\u8fc7\u8be5\u4ee3\u7406\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\uff0c\u90a3\u4e48\u95ee\u9898\u53ef\u80fd\u51fa\u5728 PathRewrite \u6216\u8005\u5176\u4ed6\u65b9\u9762\u3002<\/p>\n<p><strong>\u6392\u9664\u7f51\u7edc\u95ee\u9898\u548c\u91cd\u542f<\/strong><\/p>\n<p>\u5982\u679c\u4e0a\u8ff0\u65b9\u6cd5\u4ecd\u7136\u4e0d\u884c\uff0c\u8003\u8651\u6392\u9664\u7f51\u7edc\u4e0d\u901a\u6216\u672a\u91cd\u542f\u7684\u95ee\u9898\uff1a<\/p>\n<ul>\n<li>\u68c0\u67e5\u4f60\u7684\u7f51\u7edc\u8fde\u63a5\u662f\u5426\u6b63\u5e38<\/li>\n<li>\u5c1d\u8bd5\u91cd\u542f\u4f60\u7684 Vue \u5e94\u7528\u6216\u6d4f\u89c8\u5668<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\u7c73\u4e91\uff01\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u3002<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   win7\u81ea\u52a8\u8c03\u8282\u4eae\u5ea6\u600e\u4e48\u5173\u95ed win7\u7cfb\u7edf\u81ea\u52a8\u8c03\u8282\u4eae\u5ea6\u5173\u95ed\u6559\u7a0b\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Vue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f \u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300aVue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f \u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002 Vue \u914d\u7f6e proxy \u4f9d\u7136\u8de8\u57df\uff0c\u5982\u4f55\u89e3\u51b3\uff1f \u4f60\u63d0\u4f9b\u7684\u914d\u7f6e\u4e2d\uff0cproxy \u4ee3\u7406\u4e86\u6307\u5b9a\u8def\u5f84\u4e0b\u7684\u8bf7\u6c42\u3002\u7136\u800c\uff0c\u4f60\u9047\u5230\u8de8\u57df\u95ee\u9898\uff0c\u9700\u8981\u8fdb\u4e00\u6b65\u5904\u7406\u3002 \u68c0\u67e5\u914d\u7f6e\u662f\u5426\u6b63\u786e \u9996\u5148\uff0c\u68c0\u67e5\u4f60\u7684\u914d\u7f6e\u662f\u5426\u6b63\u786e\u3002\u6839\u636e\u4f60\u63d0\u4f9b\u7684\u4ee3\u7801\uff0c\u4f60\u7684\u914d\u7f6e\u5982\u4e0b\uff1a proxy: { &#8216;\/hyjk_authorization&#8217;: { target: &#8216;http:\/\/211.90.39.00:8089\/&#8217;, changOrigin: true, pathRewrite: { &#8216;^\/hyjk_authorization&#8217;: &#8221; } } } \u770b\u4e0a\u53bb\u5e76\u6ca1\u6709\u95ee\u9898\uff0c\u4f46\u4e3a\u4e86\u4fdd\u9669\u8d77\u89c1\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4ee3\u7406\u5230\u4e00\u4e2a\u901a\u7528\u7684 CORS \u670d\u52a1\uff0c\u4f8b\u5982\uff1a proxy: { &#8216;\/hyjk_authorization&#8217;: { target: &#8216;https:\/\/www.lilnong.top\/cors\/&#8217;, changOrigin: true, pathRewrite: { &#8216;^\/hyjk_authorization&#8217;: &#8221; } } } \u5982\u679c\u901a\u8fc7\u8be5\u4ee3\u7406\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\uff0c\u90a3\u4e48\u95ee\u9898\u53ef\u80fd\u51fa\u5728 PathRewrite \u6216\u8005\u5176\u4ed6\u65b9\u9762\u3002 \u6392\u9664\u7f51\u7edc\u95ee\u9898\u548c\u91cd\u542f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-53655","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53655"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53655\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}