Welcome Guest, Not a member yet? Register   Sign In
Best CORS Enabling in CI
#1
Question 

We are about to switch to vanilla PHP or Laravel because CI is unclear and weak when it comes to CORS handling. Whats the best and practical way of enabling CORS on CI? Please be detailed and share what you wrote and came across in the past.
Reply
#2

Hello!

As someone who has built applications requiring cors in vanilla php, laravel, and ruby on rails, I can tell you that it can be a headache wherever you go. I would not recommend changing frameworks just based on this.

There are several ways you can implement CORS, but I would start by looking into codeigniter hooks and setting the appropriate CORS headers that you require there. One issue that is always annoying is that if you have an error in your application, an ajax request will throw a CORS error instead of displaying what went wrong in your app. This is universal and mega annoying if you don't have some sort of bug tracker already installed (highly recommended!).
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#3

(07-12-2016, 02:04 PM)albertleao Wrote: Hello!

As someone who has built applications requiring cors in vanilla php, laravel, and ruby on rails, I can tell you that it can be a headache wherever you go. I would not recommend changing frameworks just based on this.

There are several ways you can implement CORS, but I would start by looking into codeigniter hooks and setting the appropriate CORS headers that you require there. One issue that is always annoying is that if you have an error in your application, an ajax request will throw a CORS error instead of displaying what went wrong in your app. This is universal and mega annoying if you don't have some sort of bug tracker already installed (highly recommended!).

Thanks Albertleao,

It is a bit easier in vanilla PHP as we have already did it but we dont want to rewrite the entire application just for that matter. We will have a single controller to call with POST data, therefore turning on hooks is a bit of an overkill. I was thinking of enabling CORS somewhat in single controller.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB