.SetIsOriginAllowed((host) => true) bunu ekleyin alttaki gibi
options.AddPolicy("AllowAll", policy =>
{
policy
.AllowAnyMethod()
.AllowAnyHeader()
.SetIsOriginAllowed((host) => true) // Tüm kaynaklara izin ver
.AllowCredentials();
});SSL sertifika kısmını kapatabilirsiniz.
hubConnection = HubConnectionBuilder()
.withUrl('https://yapayzeka.uygunstock.com/myhub',
options: HttpConnectionOptions(
skipNegotiation: true,
transport: HttpTransportType.webSockets,
client: IOClient(
HttpClient()..badCertificateCallback = (cert, host, port) => true
),
))
.build();Hatayı yakalamak içinde kodu bu şekilde güncelleyin
try {
await hubConnection.start();
// ...
} catch (e, stackTrace) {
print('Hata: $e');
print('Stack trace: $stackTrace');
setState(() {
connectionStatus = 'Bağlantı Hatası: $e';
});
}