Darkarevir
Darkarevir
CC#
Created by Darkarevir on 1/28/2025 in #help
✅ SignalR
Hello, I am doing some practices for the backend part but I have a problem when trying to use the websocket locally it works perfectly but when uploading it to the server it does not work. Here is the code var builder = WebApplication.CreateBuilder(args); var env = builder.Environment; Env.Load(); builder.WebHost.ConfigureKestrel(options => { int proxyPort = Env.GetInt("PROXY_PORT", 5000); options.ListenAnyIP(proxyPort); options.ListenAnyIP(proxyPort + 1, listenOptions => { listenOptions.UseHttps(); }); }); builder.Services.AddControllers(); builder.Services.AddSignalR(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddCors(options => { options.AddPolicy("AllowSpecificOrigins", policyBuilder => { policyBuilder .WithOrigins("mi-domain") .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); options.AddPolicy("AllowAll", policyBuilder => { policyBuilder .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); var app = builder.Build(); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseCors("AllowSpecificOrigins"); app.MapHub<UserHub>("/userhub"); if (app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(); } else { app.UseHsts(); app.UseHttpsRedirection(); } app.UseAuthentication(); app.UseAuthorization(); app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "pictures")), RequestPath = "/pictures" });
21 replies