{"id":715,"date":"2026-06-19T07:46:44","date_gmt":"2026-06-19T07:46:44","guid":{"rendered":"https:\/\/hyc.eshachem.com\/program\/?page_id=715"},"modified":"2026-06-19T07:48:19","modified_gmt":"2026-06-19T07:48:19","slug":"6-sop-cros","status":"publish","type":"page","link":"https:\/\/hyc.eshachem.com\/program\/%e7%b6%b2%e9%a0%81%e6%8a%80%e8%a1%93%e8%88%87%e8%b3%87%e5%ae%89\/6-sop-cros\/","title":{"rendered":"6. SOP &amp; CROS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728\u5b78\u5b8c\u4e86 XSS \u7684\u300c\u524d\u7aef\u5167\u9b3c\u300d\u8207 CSRF \u7684\u300c\u9694\u7a7a\u5077\u8972\u300d\u5f8c\uff0c\u4f60\u4e00\u5b9a\u6703\u60f3\u8aaa\uff1a<strong>\u300c\u96e3\u9053\u7db2\u9801\u4e16\u754c\u88e1\uff0c\u96a8\u4fbf\u4e00\u500b\u5916\u90e8\u7db2\u7ad9\u90fd\u80fd\u5c0d\u6211\u7684\u7db2\u7ad9\u6307\u624b\u756b\u8173\u3001\u6216\u662f\u5077\u770b\u6211\u7db2\u7ad9\u7684\u8cc7\u6599\u55ce\uff1f\u300d<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7576\u7136\u662f\u6c92\u53ef\u80fd\uff01\u800c\u5728\u524d\u7dda\u6b7b\u6b7b\u64cb\u4f4f\u9019\u4e00\u5207\u3001\u4fdd\u8b77\u6240\u6709\u7db2\u7ad9\u96b1\u79c1\u7684\u5e55\u5f8c\u529f\u81e3\uff0c\u5c31\u662f\u700f\u89bd\u5668\u6700\u6838\u5fc3\u7684\u5b89\u5168\u57fa\u77f3\u2014\u2014<strong>\u540c\u6e90\u653f\u7b56\uff08SOP\uff0cSame-Origin Policy\uff09<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u8aaa Cookie \u5c6c\u6027\uff08\u5982 <code>HttpOnly<\/code>\u3001<code>SameSite<\/code>\uff09\u662f\u6211\u5011\u91dd\u5c0d\u7279\u5b9a\u9470\u5319\u52a0\u88dd\u7684\u9396\uff0c\u90a3\u9ebc <strong>\u540c\u6e90\u653f\u7b56\u5c31\u662f\u700f\u89bd\u5668\u5167\u5efa\u7684\u300c\u7db2\u57df\u9632\u706b\u7246\u300d<\/strong>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"%e5%90%8c%e6%ba%90\">\u540c\u6e90?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u700f\u89bd\u5668\u8981\u5224\u65b7\u5169\u500b\u7db2\u5740\u662f\u4e0d\u662f\u300c\u81ea\u5df1\u4eba\u300d\uff0c\u6a19\u6e96\u975e\u5e38\u56b4\u683c\u3002\u5169\u500b\u7db2\u5740\u5fc5\u9808\u5728\u4ee5\u4e0b\u4e09\u500b\u5143\u7d20\u5b8c\u5168\u4e00\u6a21\u4e00\u6a23\uff0c\u624d\u7b97\u662f<strong>\u540c\u6e90<\/strong>\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u5354\u5b9a\uff08Protocol\uff09<\/strong>\uff1a\u4f8b\u5982 <code>http<\/code> \u6216 <code>https<\/code>\u3002<\/li>\n\n\n\n<li><strong>\u7db2\u57df\uff08Domain \/ Host\uff09<\/strong>\uff1a\u4f8b\u5982 <code>ntub.edu.tw<\/code> \u6216 <code>google.com<\/code>\u3002<\/li>\n\n\n\n<li><strong>\u9023\u63a5\u57e0\uff08Port\uff09<\/strong>\uff1a\u4f8b\u5982 <code>:80<\/code> \u6216 <code>:443<\/code>\uff08\u5982\u679c\u6c92\u5beb\uff0c\u700f\u89bd\u5668\u6703\u6839\u64da\u5354\u5b9a\u81ea\u5e36\u9810\u8a2d\u503c\uff09\u3002<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ea\u8981\u9019\u4e09\u500b\u5143\u7d20\u4e2d<strong>\u6709\u4efb\u4f55\u4e00\u500b\u5b57\u4e0d\u4e00\u6a23<\/strong>\uff0c\u700f\u89bd\u5668\u5c31\u6703\u5224\u5b9a\u5b83\u5011\u662f\u300c\u4e0d\u540c\u6e90\uff08Cross-Origin\uff0c\u8de8\u4f86\u6e90\uff09\u300d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u5317\u5546\u5927\u5b98\u7db2 <code>https:\/\/www.ntub.edu.tw<\/code> \u70ba\u4f8b<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>\u6bd4\u8f03\u7db2\u5740<\/strong><\/td><td><strong>\u662f\u5426\u540c\u6e90\uff1f<\/strong><\/td><td><strong>\u539f\u56e0\u5224\u5b9a<\/strong><\/td><\/tr><\/thead><tbody><tr><td><code>https:\/\/www.ntub.edu.tw\/news<\/code><\/td><td><strong>\ud83d\udfe2 \u540c\u6e90<\/strong><\/td><td>\u5354\u5b9a\u3001\u7db2\u57df\u3001Port \u5b8c\u5168\u4e00\u81f4\uff0c\u53ea\u6709\u8def\u5f91\uff08Path\uff09\u4e0d\u540c\u3002<\/td><\/tr><tr><td><code>http:\/\/www.ntub.edu.tw<\/code><\/td><td><strong>\u274c \u4e0d\u540c\u6e90<\/strong><\/td><td><strong>\u5354\u5b9a\u4e0d\u540c<\/strong>\uff08<code>http<\/code> vs <code>https<\/code>\uff09\u3002<\/td><\/tr><tr><td><code>https:\/\/api.ntub.edu.tw<\/code><\/td><td><strong>\u274c \u4e0d\u540c\u6e90<\/strong><\/td><td><strong>\u7db2\u57df\u4e0d\u540c<\/strong>\uff08\u5b50\u7db2\u57df <code>api<\/code> \u8207 <code>www<\/code> \u4e0d\u540c\uff09\u3002<\/td><\/tr><tr><td><code>https:\/\/www.ntub.edu.tw:8080<\/code><\/td><td><strong>\u274c \u4e0d\u540c\u6e90<\/strong><\/td><td><strong>\u9023\u63a5\u57e0\u4e0d\u540c<\/strong>\uff08<code>:8080<\/code> vs \u9810\u8a2d\u7684 <code>:443<\/code>\uff09\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"%e5%90%8c%e6%ba%90%e6%94%bf%e7%ad%96%e5%88%b0%e5%ba%95%e5%9c%a8%e3%80%8c%e9%99%90%e5%88%b6%e3%80%8d%e4%bb%80%e9%ba%bc%ef%bc%9f\">\u540c\u6e90\u653f\u7b56\u5230\u5e95\u5728\u300c\u9650\u5236\u300d\u4ec0\u9ebc\uff1f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f88\u591a\u521d\u5b78\u8005\u5728\u5beb Next.js \u6216 Web API \u4e32\u63a5\u6642\uff0c\u5e38\u5e38\u6703\u88ab\u540c\u6e90\u653f\u7b56\u641e\u5f97\u4e00\u982d\u9727\u6c34\uff0c\u4ee5\u70ba\u8de8\u7db2\u57df\u4ec0\u9ebc\u4e8b\u90fd\u4e0d\u80fd\u505a\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>\u540c\u6e90\u653f\u7b56\u4e3b\u8981\u9650\u5236\u7684\u662f\u300c\u7528 JavaScript \u53bb\u8b80\u53d6\u8de8\u4f86\u6e90\u7684\u8cc7\u6e90\u8207\u96b1\u79c1\u300d\uff0c\u5b83\u4e26\u4e0d\u662f\u9650\u5236\u7db2\u8def\u9023\u7dda\u672c\u8eab\u3002<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u5177\u9ad4\u4f86\u8aaa\uff0c\u5b83\u6709\u4e09\u5927\u9632\u79a6\u6230\u5834\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-%e9%99%90%e5%88%b6-dom-%e7%9a%84%e6%93%8d%e4%bd%9c\">1. \u9650\u5236 DOM \u7684\u64cd\u4f5c<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c Harry \u7684\u7db2\u9801\u88e1\u7528 <code>&lt;iframe&gt;<\/code> \u5d4c\u5165\u4e86\u4e00\u500b\u9280\u884c\u7684\u767b\u5165\u7db2\u9801\uff0cHarry \u7db2\u9801\u4e0a\u7684 JavaScript <strong>\u7d55\u5c0d\u6c92\u6709\u6b0a\u9650<\/strong>\u53bb\u6488\u53d6\u90a3\u500b\u9280\u884c <code>&lt;iframe&gt;<\/code> \u88e1\u7684\u4efb\u4f55\u6309\u9215\u3001\u8f38\u5165\u6846\u6216\u662f\u6587\u5b57\u3002\u5426\u5247\u99ed\u5ba2\u53ea\u8981\u5beb\u500b\u96b1\u85cf\u7684 iframe\uff0c\u5c31\u80fd\u7528 JS \u5929\u5929\u5077\u770b\u4f60\u5728\u5225\u5bb6\u7db2\u7ad9\u8f38\u5165\u7684\u5bc6\u78bc\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-%e9%99%90%e5%88%b6-cookie-%e8%88%87%e5%84%b2%e5%ad%98%e7%a9%ba%e9%96%93\">2. \u9650\u5236 Cookie \u8207\u5132\u5b58\u7a7a\u9593<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u7684\u700f\u89bd\u5668\u88e1\u540c\u6642\u958b\u8457\u300c\u5317\u5546\u5927\u7cfb\u7d71\u300d\u8207\u300c\u99ed\u5ba2\u7db2\u7ad9\u300d\u5169\u500b\u5206\u9801\u3002\u99ed\u5ba2\u7db2\u7ad9\u4e0a\u7684 JS \u7a0b\u5f0f\u78bc\uff0c<strong>\u7d55\u5c0d\u4e0d\u53ef\u80fd<\/strong>\u900f\u904e <code>document.cookie<\/code> \u6216 <code>localStorage<\/code> \u53bb\u5077\u770b\u6216\u8b80\u53d6\u5317\u5546\u5927\u7db2\u57df\u4e0b\u7684\u4efb\u4f55\u6578\u64da\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-%e9%99%90%e5%88%b6-fetch-api-%e7%9a%84%e3%80%8c%e5%9b%9e%e6%87%89%e8%ae%80%e5%8f%96%e3%80%8d\">3. \u9650\u5236 Fetch API \u7684\u300c\u56de\u61c9\u8b80\u53d6\u300d<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u9019\u662f\u6700\u5bb9\u6613\u8b93\u4eba\u8aa4\u89e3\u7684\u5730\u65b9\uff01\u540c\u6e90\u653f\u7b56<strong>\u4e26\u4e0d\u6703<\/strong>\u963b\u6b62\u700f\u89bd\u5668\u5c0d\u5176\u4ed6\u7db2\u7ad9\u767c\u51fa\u8acb\u6c42\u3002\u7576\u4f60\u7528 JS \u767c\u9001 <code>fetch('https:\/\/api.hacker.com')<\/code> \u6642\uff0c<strong>\u700f\u89bd\u5668\u5176\u5be6\u300c\u6709\u300d\u5e6b\u4f60\u628a\u8acb\u6c42\u9001\u51fa\u53bb\uff0c\u9060\u7aef\u4f3a\u670d\u5668\u4e5f\u300c\u6709\u300d\u6536\u5230\u4e26\u8655\u7406\u5b8c\u3001\u751a\u81f3\u628a\u56de\u61c9\uff08Response\uff09\u50b3\u56de\u7d66\u700f\u89bd\u5668\u4e86\u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7576 Response \u50b3\u56de\u700f\u89bd\u5668\u7684\u4e00\u77ac\u9593\uff0c\u700f\u89bd\u5668\u8b66\u9234\u5927\u4f5c\uff1a\u300c\u7b49\u7b49\uff01\u767c\u8d77\u8acb\u6c42\u7684\u662f <code>ntub.edu.tw<\/code>\uff0c\u4f46\u56de\u50b3\u8cc7\u6599\u7684\u662f <code>api.hacker.com<\/code>\uff0c\u9019\u4e0d\u540c\u6e90\uff01\u300d\u65bc\u662f\u700f\u89bd\u5668\u4e00\u5df4\u638c\u628a\u8cc7\u6599\u6514\u622a\u4e26\u92b7\u6bc0\uff0c\u4e26\u5728\u63a7\u5236\u53f0\uff08Console\uff09\u5674\u51fa\u4e00\u884c\u7d05\u8272\u7684\u5831\u932f\uff0c<strong>\u8b93\u4f60\u7684\u524d\u7aef\u7a0b\u5f0f\u78bc\u300c\u8b80\u53d6\u4e0d\u5230\u300d\u9019\u7b46\u8cc7\u6599<\/strong>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"%e7%b5%90%e5%90%88\">\u7d50\u5408!<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u65e2\u7136\u6709\u4e86\u540c\u6e90\u653f\u7b56\uff08SOP\uff09\uff0c\u99ed\u5ba2\u6c92\u8fa6\u6cd5\u5728\u5225\u7684\u7db2\u57df\u7528 JS \u5077\u8b80\u53d6\u6211\u7684 Cookie\uff0c\u90a3\u70ba\u4ec0\u9ebc CSRF \u9084\u80fd\u6210\u529f\uff1f\n<ul class=\"wp-block-list\">\n<li>\u56e0\u70ba CSRF \u653b\u64ca\u5229\u7528\u7684\u662f\u700f\u89bd\u5668\u7684\u81ea\u52d5\u5316\u6a5f\u5236\uff08\u767c\u51fa Request \u5c31\u9806\u4fbf\u5e36 Cookie\uff09\uff0c\u5b83<strong>\u4e0d\u9700\u8981\u300c\u8b80\u53d6\u300dCookie \u7684\u5167\u5bb9<\/strong>\u3002\u99ed\u5ba2\u53ea\u662f\u76f2\u76ee\u5730\u501f\u7528\u4f60\u7684\u8eab\u4efd\u767c\u9001\u8acb\u6c42\uff0c\u800c SOP \u53ea\u9650\u5236\u4e86\u300cJS \u53bb\u8b80\u53d6\u56de\u61c9\u300d\uff0c\u4e26\u6c92\u6709\u9650\u5236\u700f\u89bd\u5668\u300c\u9001\u51fa\u8acb\u6c42\u300d\uff0c\u6240\u4ee5 SOP \u64cb\u4e0d\u4f4f CSRF\uff01<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u70ba\u4ec0\u9ebc\u6211\u5011\u9084\u9700\u8981\u9632\u7bc4 XSS\uff1f<\/strong>\u5982\u679c XSS \u6210\u529f\uff0c\u99ed\u5ba2\u628a\u60e1\u610f JS \u4ee3\u78bc\u76f4\u63a5\u4e0b\u6bd2\u585e\u9032\u4e86\u300c\u5317\u5546\u5927\u7cfb\u7d71\u300d\u7684\u5167\u90e8\u3002\u9019\u6642\u5019\uff0c\u9019\u6bb5\u60e1\u610f\u7684 JS \u4ee3\u78bc\u5c31\u6210\u4e86\u300c\u5317\u5546\u5927\u7db2\u57df\u7684\u5167\u9b3c\u300d\u3002\n<ul class=\"wp-block-list\">\n<li>\u56e0\u70ba\u7a0b\u5f0f\u78bc\u5df2\u7d93\u8ddf\u5317\u5546\u5927\u7cfb\u7d71\u300c\u540c\u6e90\u300d\u4e86\uff0c\u540c\u6e90\u653f\u7b56\u6703\u5b8c\u5168\u653e\u884c\u3002\u9019\u6bb5\u5167\u9b3c\u4ee3\u78bc\u5c31\u80fd\u66a2\u884c\u7121\u963b\u5730\u8b80\u53d6 <code>document.cookie<\/code>\uff0c\u628a\u4f60\u7684\u96b1\u79c1\u5077\u8d70\u3002\u9019\u8b49\u660e\u4e86\u300c<strong>\u4e00\u65e6\u88ab XSS \u7834\u9632\uff0c\u540c\u6e90\u653f\u7b56\u5c31\u6703\u76f4\u63a5\u5931\u6548<\/strong>\u300d\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"cors\">CORS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u65e2\u7136\u540c\u6e90\u653f\u7b56\u9019\u9ebc\u56b4\u683c\uff0c\u90a3\u73fe\u4ee3\u524d\u5f8c\u7aef\u5206\u96e2\u7684\u67b6\u69cb\uff08\u4f8b\u5982\uff1a\u524d\u7aef Next.js \u90e8\u7f72\u5728 Vercel <code>my-app.vercel.app<\/code>\uff0c\u5f8c\u7aef API \u90e8\u7f72\u5728 AWS <code>api.my-app.com<\/code>\uff09\uff0c\u524d\u7aef\u4e0d\u5c31\u6c38\u9060\u62ff\u4e0d\u5230\u5f8c\u7aef\u7684\u8cc7\u6599\u4e86\u55ce\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u70ba\u4e86\u89e3\u6c7a\u9019\u500b\u5be6\u52d9\u4e0a\u7684\u6b63\u7576\u9700\u6c42\uff0c\u7db2\u9801\u4e16\u754c\u5141\u8a31\u5f8c\u7aef\u4f3a\u670d\u5668\u300c\u7db2\u958b\u4e00\u9762\u300d\uff0c\u9019\u500b\u6a5f\u5236\u5c31\u53eb\u505a <strong>CORS\uff08\u8de8\u4f86\u6e90\u8cc7\u6e90\u5171\u4eab\uff0cCross-Origin Resource Sharing\uff09<\/strong>\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u904b\u4f5c\u539f\u7406<\/strong>\uff1a\u7576\u524d\u7aef\u8de8\u7db2\u57df Fetch \u8cc7\u6599\u6642\uff0c\u5f8c\u7aef\u4f3a\u670d\u5668\u5fc5\u9808\u5728 Response Header \u4e2d\uff0c\u52a0\u4e0a\u4e00\u5f35\u300c\u901a\u95dc\u7279\u8a31\u8b49\u300d\uff1a<code>Access-Control-Allow-Origin: https:\/\/my-app.vercel.app<\/code><\/li>\n\n\n\n<li><strong>\u700f\u89bd\u5668\u7684\u653e\u884c\u689d\u4ef6<\/strong>\uff1a\u7576\u700f\u89bd\u5668\u6536\u5230 Response \u6642\uff0c\u770b\u5230\u9019\u884c Header\uff0c\u767c\u73fe\u5f8c\u7aef\u5927\u8166\u89aa\u53e3\u5ba3\u7a31\u300c\u6211\u9858\u610f\u8207\u9019\u500b\u524d\u7aef\u5171\u4eab\u8cc7\u6e90\u300d\uff0c\u700f\u89bd\u5668\u624d\u6703\u89e3\u9664 SOP \u7684\u9650\u5236\uff0c\u9ad8\u9ad8\u8208\u8208\u5730\u628a\u8cc7\u6599\u653e\u884c\u7d66\u524d\u7aef\u7684 JS \u8b80\u53d6\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"%e5%95%8f\">\u554f!<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Q\uff1a\u5c0f\u660e\u5728\u958b\u767c\u5c08\u6848\u6642\u9047\u5230\u4e86\u8de8\u7db2\u57df\u5831\u932f\uff08CORS error\uff09\u3002\u4ed6\u4e0a\u7db2\u67e5\u5230\u4e86\u4e00\u500b\u504f\u65b9\uff1a\u5728 Chrome \u700f\u89bd\u5668\u7684\u6377\u5f91\u5f8c\u9762\u52a0\u4e0a\u53c3\u6578 <code>--disable-web-security<\/code>\uff08\u95dc\u9589\u700f\u89bd\u5668\u5b89\u5168\u6aa2\u67e5\uff09\uff0c\u91cd\u555f\u700f\u89bd\u5668\u5f8c\uff0c\u8de8\u7db2\u57df\u7684\u5831\u932f\u771f\u7684\u6d88\u5931\u4e86\uff0c\u8cc7\u6599\u4e5f\u80fd\u6b63\u5e38\u8b80\u53d6\u3002\u5c0f\u660e\u975e\u5e38\u9ad8\u8208\uff0c\u6e96\u5099\u628a\u9019\u500b\u65b9\u6cd5\u5beb\u9032\u4ed6\u7684\u5c08\u6848\u90e8\u7f72\u8aaa\u660e\u66f8\u4e2d\u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8acb\u7528\u672c\u7ae0\u5b78\u5230\u7684\u300c\u540c\u6e90\u653f\u7b56\uff08SOP\uff09\u300d\u539f\u7406\u89e3\u91cb\uff1a\u70ba\u4ec0\u9ebc\u5c0f\u660e\u7684\u65b9\u6cd5\u662f\u6975\u5ea6\u5371\u96aa\u4e14\u4e0d\u5207\u5be6\u969b\u7684\uff1f\u771f\u6b63\u7684\u89e3\u6c7a\u65b9\u6848\u61c9\u8a72\u7531\u8ab0\uff08\u524d\u7aef\u9084\u662f\u5f8c\u7aef\uff09\u4f86\u505a\u8abf\u6574\uff1f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7b54\u6848\u5f15\u5c0e\u5efa\u8b70<\/strong>\uff1a\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u5371\u96aa\u8207\u4e0d\u5207\u5be6\u969b\u4e4b\u8655<\/strong>\uff1a\u540c\u6e90\u653f\u7b56\uff08SOP\uff09\u662f\u904b\u884c\u5728**\u300c\u4f7f\u7528\u8005\uff08\u5ba2\u6236\u7aef\uff09\u7684\u700f\u89bd\u5668\u300d**\u4e0a\u7684\u9632\u79a6\u6a5f\u5236\u3002\u5c0f\u660e\u52a0\u53c3\u6578\u53ea\u80fd\u95dc\u9589\u300c\u4ed6\u81ea\u5df1\u96fb\u8166\u4e0a\u300d\u7684\u700f\u89bd\u5668\u9632\u79a6\u3002\u7576\u5176\u4ed6\u6b63\u5e38\u7684\u5b78\u751f\u7528\u6a19\u6e96\u7684 Chrome \u700f\u89bd\u5668\u6253\u958b\u9019\u500b\u7db2\u7ad9\u6642\uff0c\u4f9d\u7136\u6703\u88ab\u540c\u6e90\u653f\u7b56\u6b7b\u6b7b\u64cb\u4f4f\u3002\u5982\u679c\u5927\u5bb6\u90fd\u95dc\u9589\u5b89\u5168\u6aa2\u67e5\uff0c\u90a3\u9ebc\u4efb\u4f55\u4e00\u500b\u91e3\u9b5a\u7db2\u7ad9\u90fd\u80fd\u8f15\u6613\u7528 JS \u5077\u8d70\u4f7f\u7528\u8005\u7684\u7db2\u9280 Cookie\uff0c\u4e16\u754c\u5c07\u9677\u5165\u8cc7\u5b89\u707d\u96e3\u3002<\/li>\n\n\n\n<li><strong>\u771f\u6b63\u89e3\u6c7a\u65b9\u6848<\/strong>\uff1a\u771f\u6b63\u7684\u89e3\u6cd5\u5fc5\u9808\u7531**\u5f8c\u7aef\u4f3a\u670d\u5668\uff08Application Server\uff09**\u4f86\u505a\u8abf\u6574\uff0c\u5728 Response \u7684 Header \u4e2d\u8a2d\u5b9a\u6b63\u78ba\u7684 <code>Access-Control-Allow-Origin<\/code> \u653f\u7b56\uff08CORS\uff09\uff0c\u5408\u6cd5\u3001\u5b89\u5168\u5730\u653e\u884c\u524d\u7aef\u7684\u8de8\u7db2\u57df\u8acb\u6c42\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\">\n\n\n\n<h2 class=\"wp-block-heading\">\u5c0f\u7d50<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u700f\u89bd\u5668\u8eab\u70ba\u53ea\u662f\u6e32\u67d3\u548c\u57f7\u884cJS\u7684\u5730\u65b9\uff0c\u80fd\u9019\u9ebc\u7528\u5fc3\u7684\u4fdd\u8b77\u6211\u5011\u5be6\u5728\u662f\u592a\u611f\u52d5\u4e86<s>(\u54ed)<\/s>\uff0c\u4f46\u6211\u5011\u4e5f\u8b1b\u5230\u4e86\uff0cSOP\u4e0d\u80fd\u5b8c\u5168\u9632\u79a6\u524d\u9762\u5b78\u5230\u7684\u5169\u7a2e\u8d85\u5371\u96aa\u653b\u64ca\uff0c\u6700\u7d42\u9084\u662f\u8981\u591a\u7a2e\u9632\u79a6\u65b9\u5f0f\u4e26\u5b58 (CORS\u3001\u8f49\u610f\u3001<code>SameSite<\/code>\u00a0Cookie\u00a0\u2026)\uff0c\u5927\u5bb6\u958b\u767c\u6642\u9700\u8981\u683c\u5916\u6ce8\u610f\u963f!<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5b78\u5b8c\u4e86 XSS \u7684\u300c\u524d\u7aef\u5167\u9b3c\u300d\u8207 CSRF \u7684\u300c\u9694\u7a7a\u5077\u8972\u300d\u5f8c\uff0c\u4f60\u4e00\u5b9a\u6703\u60f3\u8aaa\uff1a\u300c\u96e3\u9053\u7db2\u9801\u4e16\u754c\u88e1\uff0c\u96a8\u4fbf\u4e00\u500b\u5916\u90e8\u7db2\u7ad9\u90fd\u80fd\u5c0d\u6211\u7684\u7db2\u7ad9\u6307\u624b\u756b\u8173\u3001\u6216\u662f\u5077\u770b\u6211\u7db2\u7ad9\u7684\u8cc7\u6599\u55ce\uff1f\u300d \u7576\u7136\u662f\u6c92\u53ef\u80fd\uff01\u800c\u5728\u524d\u7dda\u6b7b\u6b7b\u64cb\u4f4f\u9019\u4e00\u5207\u3001\u4fdd\u8b77\u6240\u6709\u7db2\u7ad9\u96b1\u79c1\u7684\u5e55\u5f8c\u529f\u81e3\uff0c\u5c31\u662f\u700f\u89bd\u5668\u6700\u6838\u5fc3\u7684\u5b89\u5168\u57fa\u77f3\u2014\u2014\u540c\u6e90\u653f\u7b56\uff08SOP\uff0cSame-Origin Policy\uff09\u3002 \u5982\u679c\u8aaa Cookie \u5c6c\u6027\uff08\u5982 HttpOnly\u3001SameSite\uff09\u662f\u6211\u5011\u91dd\u5c0d\u7279\u5b9a\u9470\u5319\u52a0\u88dd\u7684\u9396\uff0c\u90a3\u9ebc \u540c\u6e90\u653f\u7b56\u5c31\u662f\u700f\u89bd\u5668\u5167\u5efa\u7684\u300c\u7db2\u57df\u9632\u706b\u7246\u300d\u3002 \u540c\u6e90? \u700f\u89bd\u5668\u8981\u5224\u65b7\u5169\u500b\u7db2\u5740\u662f\u4e0d\u662f\u300c\u81ea\u5df1\u4eba\u300d\uff0c\u6a19\u6e96\u975e\u5e38\u56b4\u683c\u3002\u5169\u500b\u7db2\u5740\u5fc5\u9808\u5728\u4ee5\u4e0b\u4e09\u500b\u5143\u7d20\u5b8c\u5168\u4e00\u6a21\u4e00\u6a23\uff0c\u624d\u7b97\u662f\u540c\u6e90\uff1a \u53ea\u8981\u9019\u4e09\u500b\u5143\u7d20\u4e2d\u6709\u4efb\u4f55\u4e00\u500b\u5b57\u4e0d\u4e00\u6a23\uff0c\u700f\u89bd\u5668\u5c31\u6703\u5224\u5b9a\u5b83\u5011\u662f\u300c\u4e0d\u540c\u6e90\uff08Cross-Origin\uff0c\u8de8\u4f86\u6e90\uff09\u300d\u3002 \u4ee5\u5317\u5546\u5927\u5b98\u7db2 https:\/\/www.ntub.edu.tw \u70ba\u4f8b \u6bd4\u8f03\u7db2\u5740 \u662f\u5426\u540c\u6e90\uff1f \u539f\u56e0\u5224\u5b9a https:\/\/www.ntub.edu.tw\/news \ud83d\udfe2 \u540c\u6e90 \u5354\u5b9a\u3001\u7db2\u57df\u3001Port \u5b8c\u5168\u4e00\u81f4\uff0c\u53ea\u6709\u8def\u5f91\uff08Path\uff09\u4e0d\u540c\u3002 http:\/\/www.ntub.edu.tw \u274c \u4e0d\u540c\u6e90 \u5354\u5b9a\u4e0d\u540c\uff08http vs https\uff09\u3002 https:\/\/api.ntub.edu.tw \u274c \u4e0d\u540c\u6e90 \u7db2\u57df\u4e0d\u540c\uff08\u5b50\u7db2\u57df api \u8207 www \u4e0d\u540c\uff09\u3002 https:\/\/www.ntub.edu.tw:8080 \u274c \u4e0d\u540c\u6e90 \u9023\u63a5\u57e0\u4e0d\u540c\uff08:8080 vs \u9810\u8a2d\u7684 :443\uff09\u3002 \u540c\u6e90\u653f\u7b56\u5230\u5e95\u5728\u300c\u9650\u5236\u300d\u4ec0\u9ebc\uff1f \u5f88\u591a\u521d\u5b78\u8005\u5728\u5beb Next.js \u6216 Web API \u4e32\u63a5\u6642\uff0c\u5e38\u5e38\u6703\u88ab\u540c\u6e90\u653f\u7b56\u641e\u5f97\u4e00\u982d\u9727\u6c34\uff0c\u4ee5\u70ba\u8de8\u7db2\u57df\u4ec0\u9ebc\u4e8b\u90fd\u4e0d\u80fd\u505a\u3002 \u540c\u6e90\u653f\u7b56\u4e3b\u8981\u9650\u5236\u7684\u662f\u300c\u7528 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":662,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-715","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/pages\/715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/comments?post=715"}],"version-history":[{"count":1,"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/pages\/715\/revisions"}],"predecessor-version":[{"id":720,"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/pages\/715\/revisions\/720"}],"up":[{"embeddable":true,"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/pages\/662"}],"wp:attachment":[{"href":"https:\/\/hyc.eshachem.com\/program\/wp-json\/wp\/v2\/media?parent=715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}