質問編集履歴

5

修正

2022/10/24 08:03

投稿

pom12345
pom12345

スコア12

test CHANGED
File without changes
test CHANGED
@@ -29,8 +29,8 @@
29
29
  <Directory "C:/xampp/htdocs">
30
30
  # ...
31
31
 
32
- # 実際は社内システム(httpサーバー)のアドレス
32
+ # 開発環境のアドレス
33
- Header set Access-Control-Allow-Origin *
33
+ Header set Access-Control-Allow-Origin "https://localhost:7096"
34
34
 
35
35
  Header set Access-Control-Allow-Methods "GET, POST, HEAD, OPTIONS"
36
36
  Header set Access-Control-Allow-Headers "Origin, withcredentials"
@@ -55,6 +55,13 @@
55
55
  });
56
56
  ```
57
57
 
58
+ Google Chrome警告内容
59
+ ```
60
+ Access to XMLHttpRequest at ...
61
+ from origin 'https://localhost:7096' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:7096' that is not equal to the supplied origin.
62
+ ```
63
+
64
+
58
65
  パケットキャプチャソフトの結果
59
66
  左から1回目、2回目
60
67
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-10-24/9140bb22-2032-455a-8c27-98789fe32843.png)

4

修正

2022/10/24 08:02

投稿

pom12345
pom12345

スコア12

test CHANGED
File without changes
test CHANGED
@@ -55,3 +55,7 @@
55
55
  });
56
56
  ```
57
57
 
58
+ パケットキャプチャソフトの結果
59
+ 左から1回目、2回目
60
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-10-24/9140bb22-2032-455a-8c27-98789fe32843.png)
61
+

3

修正

2022/10/24 07:44

投稿

pom12345
pom12345

スコア12

test CHANGED
File without changes
test CHANGED
@@ -52,6 +52,6 @@
52
52
  params: { value: "GETで渡すパラメーター" }
53
53
  }).catch((response) => {
54
54
  console.log("ng")
55
- });
55
+ });
56
56
  ```
57
57
 

2

修正

2022/10/24 07:39

投稿

pom12345
pom12345

スコア12

test CHANGED
File without changes
test CHANGED
@@ -16,8 +16,9 @@
16
16
 
17
17
  (調べたこと)
18
18
  https://qiita.com/nnishimura/items/1f156f05b26a5bce3672
19
+ 単純リクエストであればプリフライト・リクエストが発生しないということ。
19
- 単純リクエストであればプリフライト・リクエストが発生しないということ(withCredentials": trueがあると単純リクエストにならないみたいです。除くと単純リクエストになりますし、1回のみ実行になりますが、警告が出てしまうところが気になります。)
20
+ withCredentials": trueがあると単純リクエストにならないみたいです。
20
-
21
+ 除くと単純リクエストになりますし、1回のみ実行になりますが、警告が出てしまうところが気になります。
21
22
 
22
23
  わかるかたいらっしゃいましたらお願いします。
23
24
 

1

修正

2022/10/24 07:38

投稿

pom12345
pom12345

スコア12

test CHANGED
File without changes
test CHANGED
@@ -7,16 +7,17 @@
7
7
 
8
8
  セキュリティ上 仕方がないことですが、それを回避する方法がないか調べています。
9
9
 
10
- (調べたこと)
11
- https://qiita.com/nnishimura/items/1f156f05b26a5bce3672
12
- 単純リクエストであればプリフライト・リクエストが発生しないということ(withCredentials": trueがあると単純リクエストにならないみたいです。)
13
-
14
10
  (試したこと)
15
11
  ①axiosのHeaderから"withCredentials": trueを除くと、GETアクセスはできるのですが、
16
12
  プリフライト・リクエストは発生せず、1回実行します。 しかし、Google Chromeのコンソールに警告が出ます。
17
13
 
18
14
  ②axiosのHeaderに"withCredentials": trueをつけても、GETアクセスはできるのですが、
19
15
  プリフライト・リクエストで2回実行してしまいます。 Google Chromeのコンソールには警告が出ないです。
16
+
17
+ (調べたこと)
18
+ https://qiita.com/nnishimura/items/1f156f05b26a5bce3672
19
+ 単純リクエストであればプリフライト・リクエストが発生しないということ(withCredentials": trueがあると単純リクエストにならないみたいです。除くと単純リクエストになりますし、1回のみ実行になりますが、警告が出てしまうところが気になります。)
20
+
20
21
 
21
22
  わかるかたいらっしゃいましたらお願いします。
22
23