質問編集履歴
1
サーバーサイドのソースの記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,6 +20,72 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
+
### 該当部分のソース(サーバーサイド)
|
24
|
+
|
25
|
+
```python
|
26
|
+
|
27
|
+
# corsの設定
|
28
|
+
|
29
|
+
{
|
30
|
+
|
31
|
+
'cors': True,
|
32
|
+
|
33
|
+
'cors_params': {
|
34
|
+
|
35
|
+
'allow_origins': ('http://localhost:8080', 'http://127.0.0.1:8080'),
|
36
|
+
|
37
|
+
'allow_methods': '*',
|
38
|
+
|
39
|
+
'allow_headers': ('content-type', 'access-control-allow-origin', 'withcredentials'),
|
40
|
+
|
41
|
+
'allow_credentials': True,
|
42
|
+
|
43
|
+
},
|
44
|
+
|
45
|
+
'allowed_hosts': ('localhost', '127.0.0.1'),
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
# cookieを返却する処理が含まれる部分
|
52
|
+
|
53
|
+
class LoginView:
|
54
|
+
|
55
|
+
@api.login_manager.login_prohibited
|
56
|
+
|
57
|
+
async def on_post(self, req: Request, resp: Response):
|
58
|
+
|
59
|
+
data = await req.media()
|
60
|
+
|
61
|
+
user = await User.get(user_name=data['user_id'])
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
resp.set_cookie('user', 'user_name', httponly=False)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
api.login_manager.login_user(user)
|
70
|
+
|
71
|
+
resp.media = {
|
72
|
+
|
73
|
+
'user': {
|
74
|
+
|
75
|
+
'name': user.name,
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
23
89
|
Response Headersのaccess-control-allow-originにリクエスト元のホストホストを入れればいいと思っていたのですが、なにか違いますでしょうか?
|
24
90
|
|
25
91
|
|