Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I create this code in program.cs
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureUmbracoDefaults() .ConfigureWebHostDefaults(webBuilder => { webBuilder.ConfigureServices(services => services.AddCors(options => options.AddPolicy("MyCors", policy => { policy.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }))); webBuilder.UseStaticWebAssets(); webBuilder.UseStartup<Startup>(); }); }
and the enabled into startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("MyCors"); app.UseUmbraco() .WithMiddleware(u => { u.UseBackOffice(); u.UseWebsite(); }) .WithEndpoints(u => { u.UseInstallerEndpoints(); u.UseBackOfficeEndpoints(); u.UseWebsiteEndpoints(); }); }
But it's not applied the CORS policy and there is not any doc about it. I use U10.2.1. How to? Thanks.
I create this and it works.
Program.cs as by default code. Into the startup.cs:
Into the ConfigureServices:
services.AddCors(options => { //options.AddPolicy("AllowDashboardOrigin", // builder => builder.SetIsOriginAllowed((host) => true).WithOrigins("http://*:*", "https://*:*", "http://localhost:8080", "http://sebapi.redspace.eu", "https://sebapi.azurewebsites.net").AllowAnyMethod().AllowAnyHeader()); options.AddPolicy("AllowDashboardOrigin", builder => builder.SetIsOriginAllowed((host) => true).AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); });
Then in the Configure add before app.UseUmbraco()...:
app.UseCors("AllowDashboardOrigin");
Works with version 11.0.0 too.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
CORS in Umbraco 10: How to?
I create this code in program.cs
and the enabled into startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
But it's not applied the CORS policy and there is not any doc about it. I use U10.2.1. How to? Thanks.
I create this and it works.
Program.cs as by default code. Into the startup.cs:
Into the ConfigureServices:
Then in the Configure add before app.UseUmbraco()...:
Works with version 11.0.0 too.
is working on a reply...