mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-10-03 15:56:17 +00:00
Ohhhhh kay testing CORS :)
This commit is contained in:
@@ -47,7 +47,11 @@ UPDATE = None
|
||||
app = Flask("WGDashboard")
|
||||
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 5206928
|
||||
app.secret_key = secrets.token_urlsafe(32)
|
||||
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
|
||||
cors = CORS(app, resources={r"/api/*": {
|
||||
"origins": "*",
|
||||
"methods": "DELETE, POST, GET, OPTIONS",
|
||||
"allow_headers": ["Content-Type", "wg-dashboard-apikey"]
|
||||
}})
|
||||
|
||||
class ModelEncoder(JSONEncoder):
|
||||
def default(self, o: Any) -> Any:
|
||||
@@ -1345,6 +1349,9 @@ API Routes
|
||||
|
||||
@app.before_request
|
||||
def auth_req():
|
||||
if request.method.lower() == 'options':
|
||||
return ResponseObject(True)
|
||||
|
||||
if "api" in request.path:
|
||||
if str(request.method) == "GET":
|
||||
DashboardLogger.log(str(request.url), str(request.remote_addr), Message=str(request.args))
|
||||
@@ -1385,6 +1392,10 @@ def auth_req():
|
||||
response.status_code = 401
|
||||
return response
|
||||
|
||||
@app.route('/api/handshake', methods=["GET", "OPTIONS"])
|
||||
def API_ValidateAPIKey():
|
||||
return ResponseObject(True)
|
||||
|
||||
|
||||
@app.route('/api/validateAuthentication', methods=["GET"])
|
||||
def API_ValidateAuthentication():
|
||||
|
Reference in New Issue
Block a user