Skip to Main Content
ASP.NET Core 3 and React
book

ASP.NET Core 3 and React

by Carl Rippon
December 2019
Intermediate to advanced content levelIntermediate to advanced
598 pages
12h 21m
English
Packt Publishing
Content preview from ASP.NET Core 3 and React

Configuring the ASP.NET Core backend for staging and production

In this section, we are going to change our CORS configuration to reference appsettings.json so that it's not hardcoded. We are then going to create separate appsettings.json files for staging and production as well for working locally in development. Let's open our backend project in Visual Studio and carry out the following steps:

  1. In the StartUp class in the ConfigureServices method, let's change our call to the AddCors method to the following:
services.AddCors(options => options.AddPolicy("CorsPolicy",     builder => builder                .AllowAnyMethod()                .AllowAnyHeader()                .AllowCredentials()                .WithOrigins(Configuration["Frontend"])));

We have simply changed the origin to reference a Frontend ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET Core 5 and React - Second Edition

ASP.NET Core 5 and React - Second Edition

Carl Rippon
ASP.NET Core 5 for Beginners

ASP.NET Core 5 for Beginners

Andreas Helland, Vincent Maverick Durano, Jeffrey Chilberto, Ed Price

Publisher Resources

ISBN: 9781789950229Supplemental Content