I hope users can log in through Appleid, and each user's data will be stored in the server, and their data will be UserData.: Swift import SwiftUI import Combine class UserData: ObservableObject, Codable { @Published var items: [String] = [""] enum CodingKeys: CodingKey { case items } required init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) items = try container.decode([String].self, forKey: .items) } func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(items, forKey: .items) } init() {} } In order to achieve the effect of interacting with the server port 3000, I added NetworkManger: Swift import Combine import Foundation class NetworkManager { static let shared = NetworkManager() private init() {} func uploadUserData(userID: String, userData: UserData) -> AnyPublisher { guard let url = URL(string: "https://WEBNAME.com:3000/uploadUserData") else { fatalError("Invalid URL") } var request = URLRequest(url: url) request.httpMethod = "POST" request.addValue("application/json", forHTTPHeaderField: "Content-Type") let body: [String: Any] = [ "userID": userID, "items": userData.items ] request.httpBody = try? JSONSerialization.data(withJSONObject: body, options: []) return URLSession.shared.dataTaskPublisher(for: request) .tryMap { output in guard let response = output.response as? HTTPURLResponse, response.statusCode == 200 else { throw URLError(.badServerResponse) } return } .mapError { $0 as Error } .eraseToAnyPublisher() } func fetchUserData(userID: String) -> AnyPublisher { guard let url = URL(string: "https://WEBNAME.com:3000/fetchUserData?userID=\(userID)") else { fatalError("Invalid URL") } return URLSession.shared.dataTaskPublisher(for: url) .tryMap { output in guard let response = output.response as? HTTPURLResponse, response.statusCode == 200 else { throw URLError(.badServerResponse) } return output.data } .decode(type: UserData.self, decoder: JSONDecoder()) .mapError { $0 as Error } .eraseToAnyPublisher() } } Then now I can start creating SignInWithAppleButton to store the user's data in the server: Swift import SwiftUI import AuthenticationServices import Combine struct SignInWithAppleView: View { @EnvironmentObject var userData: UserData @State private var cancellables = Set() @Binding var isSignIn: Bool var body: some View { SignInWithAppleButton( .signIn, onRequest: { request in request.requestedScopes = [.fullName, .email] }, onCompletion: { result in switch result { case .success(let authResults): handleAuthorization(authResults: authResults) case .failure(let error): print("Authorization failed: \(error.localizedDescription)") } } ) .signInWithAppleButtonStyle(.black) .frame(width: 200, height: 45) } func handleAuthorization(authResults: ASAuthorization) { guard let appleIDCredential = authResults.credential as? ASAuthorizationAppleIDCredential else { return } let userID = appleIDCredential.user let fetchUserDataPublisher = NetworkManager.shared.fetchUserData(userID: userID) let uploadUserDataPublisher = NetworkManager.shared.uploadUserData(userID: userID, userData: self.userData) fetchUserDataPublisher .sink(receiveCompletion: { completion in switch completion { case .finished: break case .failure(let error): print("Failed to fetch user data: \(error.localizedDescription)") } }, receiveValue: { userData in self.userData.items = userData.items }) .store(in: &self.cancellables) uploadUserDataPublisher .sink(receiveCompletion: { completion in switch completion { case .finished: print("Done!") isSignIn = true case .failure(let error): print("Failed to upload user data: \(error.localizedDescription)") } }, receiveValue: { print("User data uploaded successfully") }) .store(in: &self.cancellables) } } After the client code is written, I need to add a code to the server to receive and store user information. It can automatically create a database on the server and store the user's data there (server.js): js const https = require('https'); const express = require('express'); const bodyParser = require('body-parser'); const cors = require('cors'); const fs = require('fs'); const path = require('path'); const app = express(); const port = 3000; const options = { key: fs.readFileSync('server.key'), cert: fs.readFileSync('server.cert') }; app.use(cors()); app.use(bodyParser.json()); const dataFilePath = path.join(__dirname, 'userdata.json'); if (!fs.existsSync(dataFilePath)) { fs.writeFileSync(dataFilePath, JSON.stringify({})); } app.post('/uploadUserData', (req, res) => { console.log('Received uploadUserData request'); const { userID, items } = req.body; console.log('Request data:', req.body); fs.readFile(dataFilePath, 'utf8', (err, data) => { if (err) { console.error('Error reading user data:', err); return res.status(500).send({ message: 'Error reading user data' }); } let userData = JSON.parse(data); userData[userID] = { items }; fs.writeFile(dataFilePath, JSON.stringify(userData), 'utf8', (err) => { if (err) { console.error('Error uploading user data:', err); return res.status(500).send({ message: 'Error uploading user data' }); } res.status(200).send({ message: 'UserData uploaded successfully' }); }); }); }); app.get('/fetchUserData', (req, res) => { console.log('Received fetchUserData request'); const userID = req.query.userID; console.log('Request userID:', userID); fs.readFile(dataFilePath, 'utf8', (err, data) => { if (err) { console.error('Error reading user data:', err); return res.status(500).send({ message: 'Error reading user data' }); } let userData = JSON.parse(data); if (userData[userID]) { res.status(200).json(userData[userID]); } else { res.status(404).send({ message: 'UserData not found' }); } }); }); https.createServer(options, app).listen(port, () => { console.log(`Server is running); }); Then I want to start running. I select the appropriate path on the terminal of the server and use node server.js to make the server.js in the server work normally. And I'm sure that port 3000 of my server is allowed to access, and then I started debugging in Xcode. However, when I ran it, there was a problem. After clicking SignInWithAppleButton, there was no response. Here are some important logs I filtered out: markdown Failed to upload user data: The request timed out. Authorization failed: The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1001.) Obviously, my server is slow to reply to the client, resulting in a timeout, and Apple does not provide Apple ID data normally. How can I correct my code?