teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

Application.phpの中身を記載

2018/10/04 08:33

投稿

Discord
Discord

スコア51

title CHANGED
File without changes
body CHANGED
@@ -22,4 +22,32 @@
22
22
 
23
23
 
24
24
  原因がわからず、困っております。
25
- ご教示のほど、よろしくお願いいたします。
25
+ ご教示のほど、よろしくお願いいたします。
26
+
27
+ 以下、追記です。
28
+ /src/Application.php
29
+ ```PHP
30
+ public function middleware($middlewareQueue)
31
+ {
32
+ $middlewareQueue
33
+ // Catch any exceptions in the lower layers,
34
+ // and make an error page/response
35
+ ->add(ErrorHandlerMiddleware::class)
36
+
37
+ // Handle plugin/theme assets like CakePHP normally does.
38
+ ->add(AssetMiddleware::class)
39
+
40
+ // Add routing middleware.
41
+ // Routes collection cache enabled by default, to disable route caching
42
+ // pass null as cacheConfig, example: `new RoutingMiddleware($this)`
43
+ // you might want to disable this cache in case your routing is extremely simple
44
+ ->add(new RoutingMiddleware($this, '_cake_routes_'))
45
+
46
+ // Add csrf middleware.
47
+ ->add(new CsrfProtectionMiddleware([
48
+ 'httpOnly' => false
49
+ ]));
50
+
51
+ return $middlewareQueue;
52
+ }
53
+ ```

1

エラーログについてもコード機能を使い修正

2018/10/04 08:33

投稿

Discord
Discord

スコア51

title CHANGED
File without changes
body CHANGED
@@ -13,10 +13,13 @@
13
13
  FormHelperを使用してフォームも作っているのですが、submitした後、「CSRF token mismatch」のエラーが吐かれ、404ページに移動してしまいます。
14
14
 
15
15
  エラーログ
16
+ ```エラーログ
16
17
  Error: [Cake\Http\Exception\InvalidCsrfTokenException] CSRF token mismatch.
17
18
  ..
18
19
  ..
19
20
  /hoge/vendor/cakephp/cakephp/src/Controller/Component/CsrfComponent.php(103): Cake\Controller\Component\CsrfComponent->_validateToken(Object(Cake\Http\ServerRequest))
21
+ ```
20
22
 
23
+
21
24
  原因がわからず、困っております。
22
25
  ご教示のほど、よろしくお願いいたします。