Custom codeiginiter app cors error

Keywords: LAMP/MAMP/WAMP - AWS - Technical issue - Application configuration

bnsupport ID: 52fdcee9-1dcd-6015-44d2-2acf6eac0d9d

bndiagnostic output:

? Apache: Found possible issues
? Resources: Found possible issues
https://docs.bitnami.com/general/apps/wordpress/troubleshooting/debug-errors-apache/
https://docs.bitnami.com/bch/apps/moodle/troubleshooting/deny-connections-bots-apache/
https://docs.bitnami.com/installer/faq/linux-faq/administration/increase-memory-linux/

bndiagnostic failure reason: The suggested guides are not related with my issue

Description:
I have created a custom app and running application. It’s working fine but when I try using API from this application to our Ionic APP. It gives below error.

Access to XMLHttpRequest at ‘https://xyz.com/Api/auth/notice?uuid=65b9855e-e4fc-4182-8894-27fd9aba0858’ from origin ‘http://localhost:8100’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: The ‘Access-Control-Allow-Origin’ header contains multiple values ‘*, *’, but only one is allowed.

I am a beginner to AWS and binami so, unable to find how to solve this that ionic app can access it.

Thanks

@fdepaz Have you any idea about it. Please help me.

Thanks

Hi @rakeshkumar125,

Thank you for using our solution. That’s a specific question about the Apache and its configuration so we suggest you ask in an Apache-specific forum or review its documentation to get more information about it. (You probably need to change the value of that parameter to *, not *, *)

However, we will also keep this ticket open in this forum in case any Bitnami user configured the application they way you want to.

Thanks

@jota Thanks for your reply I was google for it and found one more link that was related to our problem which is below.

https://community.magento.com/t5/Magento-2-x-Hosting-Performance/Accessing-Magento-REST-APIs-from-localhost-Blocked-by-CORS/td-p/449212

I have added below code in file (/opt/bitnami/apache/htdocs/my-app/.htaccess).

    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Headers "Content-Type, Authorization"
    Header always set Access-Control-Allow-Methods "GET"
    Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location"
    Header always set Access-Control-Max-Age "600"

    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^(.*)$ $1 [R=200,L]

Then error is removed & API start working.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.