質問編集履歴
1
test.comをexample.comに
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jQueryとFlask
|
1
|
+
jQueryとFlaskをサーバー上で連携したいがうまくいかない
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
app.pyはポート5400で動かします。
|
9
9
|
|
10
10
|
```ファイルのディレクトリ構成
|
11
|
-
url: https://
|
11
|
+
url: https://example.com/test
|
12
12
|
- front
|
13
13
|
index.html
|
14
14
|
- backend
|
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
```エラー
|
29
29
|
jquery-3.6.4.min.js:2
|
30
|
-
POST https://
|
30
|
+
POST https://example.com:5240/test/backend/data net::ERR_CONNECTION_TIMED_OUT
|
31
31
|
```
|
32
32
|
|
33
33
|
|
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
$.ajax({
|
60
60
|
type: 'POST',
|
61
|
-
url: 'https://
|
61
|
+
url: 'https://example.com/test/backend/data',
|
62
62
|
contentType: 'application/json;charset=UTF-8',
|
63
63
|
data: JSON.stringify(dataToSend),
|
64
64
|
success: function (response) {
|
@@ -80,7 +80,7 @@
|
|
80
80
|
from flask_cors import CORS
|
81
81
|
|
82
82
|
app = Flask(__name__)
|
83
|
-
CORS(app, resources={r"/test/backend/*": {"origins": "https://
|
83
|
+
CORS(app, resources={r"/test/backend/*": {"origins": "https://example.com"}})
|
84
84
|
|
85
85
|
@app.route('/test/backend/data', methods=['POST'])
|
86
86
|
def receive_data():
|
@@ -95,22 +95,22 @@
|
|
95
95
|
|
96
96
|
```000-default.conf
|
97
97
|
<VirtualHost *:80>
|
98
|
-
ServerName
|
98
|
+
ServerName example.com
|
99
|
-
ServerAlias www.
|
99
|
+
ServerAlias www.example.com
|
100
|
-
Redirect permanent / https://
|
100
|
+
Redirect permanent / https://example.com/
|
101
101
|
</VirtualHost>
|
102
102
|
|
103
103
|
<VirtualHost *:443>
|
104
|
-
ServerName
|
104
|
+
ServerName example.com
|
105
|
-
ServerAlias www.
|
105
|
+
ServerAlias www.example.com
|
106
106
|
|
107
107
|
DocumentRoot /var/www/html/
|
108
108
|
#DocumentRoot /var/www/html/test/front/
|
109
109
|
|
110
110
|
SSLEngine on
|
111
|
-
SSLCertificateFile /etc/letsencrypt/live/
|
111
|
+
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
|
112
|
-
SSLCertificateKeyFile /etc/letsencrypt/live/
|
112
|
+
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
|
113
|
-
SSLCertificateChainFile /etc/letsencrypt/live/
|
113
|
+
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
|
114
114
|
|
115
115
|
# Log files
|
116
116
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
@@ -159,8 +159,8 @@
|
|
159
159
|
- [ ] その他
|
160
160
|
|
161
161
|
##### 上記の詳細・結果
|
162
|
-
ajax部分のurlを url: 'https://
|
162
|
+
ajax部分のurlを url: 'https://example.com:5400/test/backend/data', にしたり、
|
163
|
-
CORSの部分を、CORS(app, resources={r"/test/backend/*": {"origins": "https://
|
163
|
+
CORSの部分を、CORS(app, resources={r"/test/backend/*": {"origins": "https://example.com:5400"}}) にするなど色々やってみたのですが、エラーは同じでうまく行きませんでした。
|
164
164
|
|
165
165
|
### 補足
|
166
166
|
特になし
|