-
Notifications
You must be signed in to change notification settings - Fork 805
Enable CORS For Serenity Applications
Victor Tomaili edited this page May 3, 2021
·
1 revision
public void ConfigureServices(IServiceCollection services)
{
services.AddAntiforgery(options => options.HeaderName = "X-CSRF-TOKEN");
//add following code for enabling cors to the project
services.AddCors(options =>
{
options.AddPolicy("AllowAllOrigin",
builder => builder.AllowAnyOrigin());
});
// code ends here
services.AddMvc(options =>
{
//options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
};
});
// ...
// ...
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// ...
// ...
app.UseDynamicScripts();
// use CORS here
app.UseCors("AllowAllOrigin");
app.UseMvc(routes =>`
{
});
// ....
Copyright © Serenity Platform 2017-present. All rights reserved.
Documentation | Serene Template | Live Demo | Premium Support | Issues | Discussions