{"id":1863,"date":"2022-09-21T13:04:35","date_gmt":"2022-09-21T04:04:35","guid":{"rendered":"https:\/\/www.miracleave.co.jp\/contents\/?p=1863"},"modified":"2023-05-22T10:47:13","modified_gmt":"2023-05-22T01:47:13","slug":"post-1863","status":"publish","type":"post","link":"https:\/\/www.miracleave.co.jp\/contents\/1863\/post-1863\/","title":{"rendered":"Docker\u3067Python\u00d7Django\u00d7Vue.js\u306e\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b(CORS\u8a8d\u8a3c\u7de8)"},"content":{"rendered":"\n<p>\u3053\u3093\u306b\u3061\u306f\u3001\u7af9\u6751\u3067\u3059\uff01ELDEN RING\u304c\u65e5\u672c\u30b2\u30fc\u30e0\u5927\u8cde\u3067\u5927\u8cde\u3092\u7372\u5f97\u3057\u307e\u3057\u305f\u306d\uff01\u81ea\u5206\u306f\u305a\u3063\u3068DLC\u304c\u51fa\u308b\u306e\u3092\u5fc3\u5f85\u3061\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u3002\u3002<\/p>\n\n\n\n<p>\u3055\u3066\u3001\u524d\u56de\u300c<a href=\"https:\/\/www.miracleave.co.jp\/contents\/1715\/post-1715\/#toc4\" target=\"_blank\" rel=\"noopener\">Docker\u3067Python\u00d7Django\u00d7Vue.js\u306e\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b(\u30b5\u30fc\u30d0\u30fc\u8d77\u52d5\u7de8)<\/a>\u300d\u3067\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3068\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306e\u30b5\u30fc\u30d0\u30fc\u8d77\u52d5\u307e\u3067\u306e\u8a2d\u5b9a\u5468\u308a\u306b\u3064\u3044\u3066\u66f8\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u30012\u3064\u306e\u30b5\u30fc\u30d0\u30fc\u9593\u306e\u901a\u4fe1\u3092\u884c\u3046\u305f\u3081\u306b\u5fc5\u8981\u306aCORS\uff08Cross-Origin Resource Sharing\uff1a\u30aa\u30ea\u30b8\u30f3\u9593\u30ea\u30bd\u30fc\u30b9\u5171\u6709\uff09\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u89e6\u308c\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u304a\u3001\u30d5\u30a9\u30eb\u30c0\u3084\u30a2\u30d7\u30ea\u69cb\u6210\u306b\u3064\u3044\u3066\u306f\u524d\u56de\u306e\u8a18\u4e8b<a href=\"https:\/\/www.miracleave.co.jp\/contents\/1715\/post-1715\/#toc4\" target=\"_blank\" rel=\"noopener\">Docker\u3067Python\u00d7Django\u00d7Vue.js\u306e\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b(\u30b5\u30fc\u30d0\u30fc\u8d77\u52d5\u7de8)<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CORS\u3068\u306f<\/h2>\n\n\n\n<p>CORS\uff08Cross-Origin Resource Sharing\uff1a\u30aa\u30ea\u30b8\u30f3\u9593\u30ea\u30bd\u30fc\u30b9\u5171\u6709\uff09\u3068\u306f\u3001\u7570\u306a\u308b\u30aa\u30ea\u30b8\u30f3\uff08\u30d7\u30ed\u30c8\u30b3\u30eb\uff0b\u30db\u30b9\u30c8\uff0b\u30dd\u30fc\u30c8\uff09\u306e\u9593\u3067\u901a\u4fe1\u3092\u8a31\u53ef\u3057\u3001\u30ea\u30bd\u30fc\u30b9\u3092\u5171\u6709\u3059\u308b\u4e8b\u3067\u3059\u3002<br>\u8a73\u3057\u304f\u306f\u5272\u611b\u3057\u307e\u3059\u304c\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u304c\u3068\u3066\u3082\u826f\u304f\u307e\u3068\u307e\u3063\u3066\u3044\u307e\u3057\u305f\uff01<\/p>\n\n\n\n<p><a href=\"https:\/\/zenn.dev\/riko\/articles\/cors_deepen_understanding\">https:\/\/zenn.dev\/riko\/articles\/cors_deepen_understanding<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">django-cors-headers<\/h2>\n\n\n\n<p>Django\u3067CORS\u3092\u6271\u3046\u70ba\u306b\u3001django-cors-headers\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<br>requirements.txt\u306b\u4ee5\u4e0b\u3092\u8a18\u8f09\u3057\u3001Docker\u30b3\u30f3\u30c6\u30ca\u3092\u7acb\u3061\u4e0a\u3052\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>django-cors-headers==3.11.0<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">setting.py<\/h2>\n\n\n\n<p>settings.py\u3092\u7de8\u96c6\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>INSTALLED_APPS\u3068MIDDLEWARE\u306b\u3001\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>INSTALLED_APPS = [\n\u3000\u3000\u30fb\u30fb\u30fb\u3000\n    &#39;corsheaders&#39;,\n]\n\nMIDDLEWARE = [\n\u3000\u3000\u30fb\u30fb\u30fb\n    &#39;corsheaders.middleware.CorsMiddleware&#39;,\n]\n<\/code><\/pre><\/div>\n\n\n\n<p>\u6b21\u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>CORS_ALLOWED_ORIGINS = [\n    &#39;http:\/\/localhost:8080&#39;,\n    &#39;http:\/\/127.0.0.1:8080&#39;,\n]\n\nCORS_ALLOW_CREDENTIALS = True<\/code><\/pre><\/div>\n\n\n\n<p>CORS_ALLOWED_ORIGINS\u306f\u3001\u901a\u4fe1\u3092\u8a31\u53ef\u3059\u308b\u5bfe\u8c61\u306eIP\u3068\u30dd\u30fc\u30c8\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<br>\u4eca\u56de\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5074\u3067\u4f7f\u7528\u3059\u308b\u30dd\u30fc\u30c8\u306f8080\u3067\u3059\u306e\u3067\uff08\u524d\u56de\u8a18\u4e8b\u306edocker-compose.yml\u3092\u53c2\u7167\uff09\u3001<br>&#8216;http:\/\/localhost:8080&#8217;\u3068\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>CORS_ALLOW_CREDENTIALS\u306f\u3001True\u306b\u8a2d\u5b9a\u3059\u308b\u4e8b\u3067Cookie \u3092\u30af\u30ed\u30b9\u30aa\u30ea\u30b8\u30f3\u306e HTTP \u30ea\u30af\u30a8\u30b9\u30c8\u306b\u542b\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u8a73\u3057\u304f\u306fdjango-cors-headers\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/pypi.org\/project\/django-cors-headers\/\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d42\u308f\u308a\u306b<\/h2>\n\n\n\n<p>Docker\u74b0\u5883\u3067\u3075\u305f\u3064\u306e\u7570\u306a\u308b\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3061\u4e0a\u3052\u3066\u69cb\u7bc9\u3059\u308b\u306b\u3042\u305f\u3063\u3066\u3001\u6700\u521d\u306b\u3064\u307e\u305a\u3044\u305f\u306e\u304cCORS\u8a8d\u8a3c\u3067\u3057\u305f\u3002<br>setting.py\u306b\u8a18\u8f09\u3059\u308b\u74b0\u5883\u5909\u6570\u306b\u3064\u3044\u3066\u306f\u60c5\u5831\u304c\u53e4\u304f\u306a\u308b\u53ef\u80fd\u6027\u3082\u3042\u308b\u306e\u3067\u3001\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3059\u308b\u4e8b\u3092\u63a8\u5968\u3057\u307e\u3059\u3002<br><br>\u3053\u306e\u8a18\u4e8b\u304c\u3001\u540c\u3058\u3088\u3046\u306a\u5883\u9047\u306e\u65b9\u306e\u4e00\u52a9\u3068\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3067\u306f\u307e\u305f\u304a\u4f1a\u3044\u3057\u307e\u3057\u3087\u3046\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u7af9\u6751\u3067\u3059\uff01ELDEN RING\u304c\u65e5\u672c\u30b2\u30fc\u30e0\u5927\u8cde\u3067\u5927\u8cde\u3092\u7372\u5f97\u3057\u307e\u3057\u305f\u306d\uff01\u81ea\u5206\u306f\u305a\u3063\u3068DLC\u304c\u51fa\u308b\u306e\u3092\u5fc3\u5f85\u3061\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u3002\u3002 \u3055\u3066\u3001\u524d\u56de\u300cDocker\u3067Python\u00d7Django\u00d7Vue.js\u306e\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b( [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":1723,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"swell_btn_cv_data":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[35,24,34,79],"class_list":["post-1863","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-django","tag-docker","tag-python","tag-vue-js"],"jetpack_featured_media_url":"https:\/\/www.miracleave.co.jp\/contents\/wp-content\/uploads\/2022\/07\/docker-eyecatch.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/posts\/1863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/comments?post=1863"}],"version-history":[{"count":13,"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/posts\/1863\/revisions"}],"predecessor-version":[{"id":2328,"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/posts\/1863\/revisions\/2328"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/media\/1723"}],"wp:attachment":[{"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/media?parent=1863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/categories?post=1863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.miracleave.co.jp\/contents\/wp-json\/wp\/v2\/tags?post=1863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}