Base solution for your next web application
Open Closed

CORS Policy not applying on specific app services using EnableCors attribute #5904


User avatar
0
muradkayani created

I want only a few app services to be exposed as public APIs without specifying origin of the site in appsettings.json All other app service should work only for allowd origins in appsettings.json

For this i have defined cors policy as folloing

Fnd using EnableCors Attribute on app service

[EnableCors("AllowAll")] public class GuideReaderAppService : GuideBuddyAppServiceBase, IGuideReaderAppService { ...

while searching support forum i have read a few question but no help for example this one

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @muradkayani

    Does it work if you use [EnableCors("AllowAll")] for a regular ASP.NET Core Controller ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @muradkayani any news ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muradkayani created

    Hi, i was busy in some other priority items.

    Anyhow while it did not work for a simple controller as well and i think this is the reason behind.

    it appears that we are mixing two different approaches for enabeling CORS which is not recommended as stated in the above link.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muradkayani created

    while i disbale middleware it caused some framework enpoints to stop working so as a workaround i did this for now but its not a clean approch, but its working fine.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)