• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CORS Usage in Controller

#1
Hi,

I was working on security of API. Did anyone let me know how we can apply CORS in elegant way?

Or what you recommend for Security of API to not expose to outer world?
.NET and CodeIgniter Software Engineer 
Reply

#2
I do it like this for fonts for security you may need to do it different.

Code:
    # Add Font Types
    AddType application/vnd.ms-fontobject .eot
    AddType font/truetype .ttf
    AddType font/opentype .otf
    AddType font/opentype .woff
    AddType font/opentype .woff2
    AddType image/svg+xml .svg .svgz

    <FilesMatch ".(eot|ttf|otf|woff|woff2|svg|svgz)">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>

You can read all about it from the link below.

Cross-Origin Resource Sharing (CORS)
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(04-12-2019, 03:19 PM)InsiteFX Wrote: I do it like this for fonts for security you may need to do it different.

Code:
    # Add Font Types
    AddType application/vnd.ms-fontobject .eot
    AddType font/truetype .ttf
    AddType font/opentype .otf
    AddType font/opentype .woff
    AddType font/opentype .woff2
    AddType image/svg+xml .svg .svgz

    <FilesMatch ".(eot|ttf|otf|woff|woff2|svg|svgz)">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>

You can read all about it from the link below.

Cross-Origin Resource Sharing (CORS)


what if I want to allow one controller to only abc.com and other controller to xyz.com?
.NET and CodeIgniter Software Engineer 
Reply

#4
Access-Control-Allow-Origin: http://your.com/controller1
Access-Control-Allow-Origin: http://your.com/controller2

Change your.com to your site and controller# to your controllers.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.