简体   繁体   中英

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

In php you can add these:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM