top of page

Add CORS To gRPC-Web Server - C# & .NET

If you separate front and back end, you may have CORS issue. The CORS issue can happen if you assign different ports or use different domain.

This example shows how to add CORS to open a service to ALL external addresses to simplify the code. In any production environment, this is NOT a safe option. You must use CORS policy to allow only certain number of external addresses. Before starting this, please make sure that you have gRPC-Web server feature already added to your gRPC service project.

 

Add the following lines of codes to Program.cs file.


Then add the following lines of codes (in the app section of Program.cs):


 

Congrats! You are all set.

pngegg (11)_result.webp

<Raank:랑크 /> 구독 하기 : Subscribe

감사합니다! : Thanks for submitting!

bottom of page