General Questions
How to add CORS to allow access to services
Cross-Origin Resource Sharing (CORS) is a mechanism that allows restricted resources on a Web Page to be requested from another domain outside the domain from which the first resource was served.
Beatrix solutions are generated with Web Apps served by a BFF service, which is served in the same domain as the back-end services. Due to this strategy, the generated solution does not come with a configured CORS policy.
If you are developing your Web App outside the Beatrix solution and serving it through another domain, you will need to configure CORS manually. There are 3 ways Microsoft recommends enabling the CORS policy in its Web Api and you should choose the best option for your scenario:
-
In middleware using a named policy
or default policy
.
-
Using endpoint routing
.
-
With the EnableCors attribute
.
If the Identity service is hosted on a different domain than your Web App, you might also need to configure CORS for IdentityServer4. For this, see the options offered in the Official Documentation , keeping in mind to implement the safest way for your scenario.
Note
Pay attention to the fact that services use Autofac as an IoC Container, if you need to register resources in the service.
How to use OData + examples
Beatrix generates Apis with support for REST queries using the OData protocol. For more information see:
Migration usage guide
Should I commit generated migrations in the Beatrix branch?
Generate into a new feature branch and then merge with the master/main branch, the Beatrix branch is exclusive to receive the generated source. Beatrix does not generate migration in the source generation flow.
This flow is our recommendation for each user / team to execute their flow according to their particularities / work philosophy.