user3397260
user3397260

Reputation: 271

No 'Access-Control-Allow-Origin' Ionic PhpMyAdmin

Hello all I am trying to create an application that would drag some components inside a database from PhpMyAdmin. I am using Ionic 3 for creating the application and php for receiving the Data from the database. The application seems to communicate fine with the database as i can add new attributes inside the database using the ionic application. The problem is that I cannot retrieve the data from the database and display them inside the mobile application. Running the application along with the console log I get this error 'Failed to load http://localhost/ionic-php-mysql/manage-data.php: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http: //localhost:8100' is therefore not allowed access.' I have installed this plugin in chrome browser, Allow-Control-Allow-Origin. And my application was working fine in chrome but not in the other browsers is it a way that I can fix my application to run in all the browsers fine without the use of this plugin, let’s say adding some block of code somewhere that will automatically fix this problem, I am quite new to ionic and I can’t find any solution, does anyone knows how this can be fixed?

Thank you in Regards

Upvotes: 0

Views: 652

Answers (1)

user9032546
user9032546

Reputation:

In php you can add these:

header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept, Origin");

Upvotes: 0

Related Questions