Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
Aplicación Net Core Webapi/SignalR bloqueada por la política CORS (netcore 5 con net framework 4.7.2. Consumidor FE)

Tengo un net framework 4.7.2 FE que me gustaría consumir una nueva aplicación netcore 5 webapi/signalR.

En este momento, tengo ambos ejecutándose en mi máquina con FE en VS2017 bajo IIS local ( https://local.redacted.com ) y el último en VS2019 IIS Express y ambos se amplían con el botón de reproducción/depuración.

Instalé cors nuget para netcore y tengo lo siguiente en mi inicio:

 public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddCors(c => { c.AddPolicy( "AllowCCORSOrigin", options => options.WithOrigins("https://local.redacted.com/") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddControllers(); services.AddSingleton<KillChecker>(); services.AddHttpContextAccessor(); services.AddSignalR().AddMessagePackProtocol(); services.AddSignalR( o => { o.EnableDetailedErrors = true; }); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseFileServer(); //needed? app.UseStaticFiles(); app.UseRouting(); app.UseCors(builder => { builder .WithOrigins("https://local.redacted.com/") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapHub<KillHub>("/killhub"); }); } }

También decoré mi controlador de lanzamiento con:

 [Route("[controller]"), EnableCors()] public class LaunchController : Controller

Desde la aplicación FE recibo el siguiente error CORS cuando ejecuto mi JS:

 const options = { method: "POST", body: JSON.stringify(params), headers: { 'content-type': "application/json" } }; fetch("https://localhost:60907/Launch", options) .then(response => response.json()) .then(data => console.log(data)) .then(console.log('lift off'));

El acceso para buscar en 'https://localhost:60907/Launch' desde el origen 'https://local.redacted.com' ha sido bloqueado por la política de CORS: la respuesta a la solicitud de verificación previa no pasa la verificación de control de acceso: Sin 'Acceso El encabezado -Control-Allow-Origin' está presente en el recurso solicitado. Si una respuesta opaca satisface sus necesidades, establezca el modo de la solicitud en 'no-cors' para obtener el recurso con CORS deshabilitado.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!