From 23692377e8ba218253f9170bff0de3b77acf8c4b Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Sat, 11 Jun 2022 00:20:43 +0200 Subject: [PATCH] Use header instead of url parameter --- Sources/App/routes.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift index 94e9b24..e95fd12 100755 --- a/Sources/App/routes.swift +++ b/Sources/App/routes.swift @@ -4,7 +4,9 @@ import Vapor private let decoder = JSONDecoder() private func authorize(_ request: Request) throws { - let key = try request.query.get(String.self, at: "key") + guard let key = request.headers.first(name: "key") else { + throw Abort(.badRequest) + } guard server.hasAuthorization(for: key) else { throw Abort(.forbidden) }