質問編集履歴
2
curlコマンドの結果の追加
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Next.jsとNginx間のcorsの設定が上手くいかない
|
1
|
+
Next.jsとNginx+Django間のcorsの設定が上手くいかない
|
body
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
・バックエンド: Docker + Nginx + Django
|
6
6
|
|
7
7
|
そしてこの2つのサーバー間でデータのやり取りがしたいのですが、corsの設定が上手く行きません
|
8
|
+
uwsgiを使用しているのでそちらの問題かもしれません
|
8
9
|
よろしくお願いします
|
9
10
|
|
10
11
|
### 発生している問題・エラーメッセージ
|
@@ -132,4 +133,28 @@
|
|
132
133
|
devツールでヘッダーを見てみると`Access-Control-Allow-Origin`が追加されていないようです
|
133
134
|
設定が間違えているんでしょうか?
|
134
135
|

|
135
|
-

|
136
|
+

|
137
|
+
|
138
|
+
### curlコマンドを叩いてみた結果
|
139
|
+
```
|
140
|
+
❯ curl -i -XOPTIONS -H 'Access-Control-Request-Method: POST' -H Origin:localhost:3000 localhost:8000
|
141
|
+
HTTP/1.1 200 OK
|
142
|
+
Server: nginx
|
143
|
+
Date: Thu, 15 Jul 2021 07:35:46 GMT
|
144
|
+
Content-Type: text/html; charset=utf-8
|
145
|
+
Content-Length: 0
|
146
|
+
Connection: keep-alive
|
147
|
+
Vary: Origin
|
148
|
+
Access-Control-Allow-Origin: localhost:3000
|
149
|
+
Access-Control-Allow-Headers: accept, accept-encoding, authorization, content-type, dnt, origin, user-agent, x-csrftoken, x-requested-with
|
150
|
+
Access-Control-Allow-Methods: DELETE, GET, OPTIONS, PATCH, POST, PUT
|
151
|
+
Access-Control-Max-Age: 86400
|
152
|
+
X-Content-Type-Options: nosniff
|
153
|
+
Referrer-Policy: same-origin
|
154
|
+
Access-Control-Allow-Origin: http://localhost
|
155
|
+
Access-Control-Allow-Headers: Origin, Authorization, Accept, Content-Type
|
156
|
+
Access-Control-Allow-Methods: POST, GET, OPTIONS
|
157
|
+
Access-Control-Allow-Credentials: true
|
158
|
+
Content-Type: text/plain charset=UTF-8
|
159
|
+
Content-Length: 0
|
160
|
+
```
|
1
実際に通信した時のヘッダーの情報を追加しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -126,4 +126,10 @@
|
|
126
126
|
|
127
127
|
OS: macOS 10.15.7
|
128
128
|
Next.js: 11.0.1
|
129
|
-
nginx: 1.21.1
|
129
|
+
nginx: 1.21.1
|
130
|
+
|
131
|
+
### 実際に通信した時のヘッダー
|
132
|
+
devツールでヘッダーを見てみると`Access-Control-Allow-Origin`が追加されていないようです
|
133
|
+
設定が間違えているんでしょうか?
|
134
|
+

|
135
|
+

|