I have a application with front end as angular js and api in node.js. Lately, i am unable to use anything due to CORS policy issue. . I tried adding permission in apache virtual host , but nothing seems to be working . Following is the issue statement visible in console. Please help
Access to XMLHttpRequest at ‘https://app.getmanagly.com:3008/login/member/validateMember’ from origin ‘https://app.getmanagly.com’ has been blocked by CORS policy: The ‘Access-Control-Allow-Origin’ header has a value ‘https://app.getmanagly.com:3008’ that is not equal to the supplied origin.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
@aha any luck over the problem …still stuck with this for long time :(
Forgive me if you already know this, but I’m giving all the info in case someone else has the same issue…
The CORS Access-Control-Allow-Origin line expects in one of these two formats:
Allow everything: probably not what you want
Access-Control-Allow-Origin: *
Allow a single specific origin:
Access-Control-Allow-Origin: [SCHEME]://[HOST]:[PORT_OPTIONAL]
subdomain.domain.com or domain.com:80 if your scheme is HTTP and :443 if your scheme is HTTPS.So I think the port is causing your issue: your config is currently only allowing requests from origin https://app.getmanagly.com:3008 and you need it to allow requests from https://app.getmanagly.com AKA https://app.getmanagly.com:443
Solution: you have three options
Header set Access-Control-Allow-Origin: *
https://app.getmanagly.comHeader set Access-Control-Allow-Origin: https://app.getmanagly.com
SetEnvIf Origin "https://app.getmanagly.com(:3008)?$" AccessControlAllowOrigin=$0
Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
FINAL IMPORTANT STEPS:
In order for this to take effect, you need to reload apache AND enable headers
apachectl -tsudo service apache2 reload or apachectl -k gracefula2enmod headersGet paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.