diff --git a/back-end/www/__init__.py b/back-end/www/__init__.py index 10e05f1..1768069 100644 --- a/back-end/www/__init__.py +++ b/back-end/www/__init__.py @@ -12,4 +12,4 @@ else: app.config.from_object("www.settings.ProductionConfig") app.register_blueprint(api, url_prefix='/api') # 注册蓝图api -cors = CORS(app, supports_credentials=True) # 允许跨域 \ No newline at end of file +cors = CORS(app, resources={r"/api/*": {"origins": "https://fluctus.cc"}}, supports_credentials=True) # 允许跨域 \ No newline at end of file diff --git a/front-end/src/api/ajax.js b/front-end/src/api/ajax.js index 9e0a2bf..318be63 100644 --- a/front-end/src/api/ajax.js +++ b/front-end/src/api/ajax.js @@ -4,6 +4,8 @@ */ import axios from 'axios' +axios.defaults.withCredentials = true; + export default function ajax(url, data = {}, type = 'GET') { if(process.env.NODE_ENV == 'production') url = 'https://api.fluctus.cc' + url return new Promise((resolve) => { diff --git a/front-end/vite.config.js b/front-end/vite.config.js index e2a3e13..d47b7ff 100644 --- a/front-end/vite.config.js +++ b/front-end/vite.config.js @@ -13,7 +13,7 @@ export default defineConfig({ }, server: { proxy: { - "/api": "https://api.fluctus.cc", + "/api": "http://localhost:5000", }, }, }) \ No newline at end of file