From c8dc729b7a89945c4d3235d74586818c9568099a Mon Sep 17 00:00:00 2001 From: Ronald Mannak Date: Tue, 6 Feb 2024 21:22:15 -0800 Subject: [PATCH] Fix server crash on iOS requests --- Sources/App/Middleware/AppStoreAuthenticator.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/App/Middleware/AppStoreAuthenticator.swift b/Sources/App/Middleware/AppStoreAuthenticator.swift index 8c4207f..d172ed2 100644 --- a/Sources/App/Middleware/AppStoreAuthenticator.swift +++ b/Sources/App/Middleware/AppStoreAuthenticator.swift @@ -64,6 +64,7 @@ struct AppStoreAuthenticator: HBAsyncAuthenticator { // (in the iOS and macOS client app: Bundle.main.appStoreReceiptURL) // However, the receipt is not available when testing in Xcode Sandbox, // so the server accepts a transaction Id in sandbox mode as well + let request = try await request.collateBody().get() guard let buffer = request.body.buffer, let body = buffer.getString(at: buffer.readerIndex, length: buffer.readableBytes) else { request.logger.error("/appstore invoked without app store receipt or transaction id in body") throw HBHTTPError(.badRequest)