Score:0

Header set Access-Control-Allow-Origin code added but nothing is happening

ne flag

I am trying to solve the below option on my website

Strict-Transport-Security
Content-Security-Policy 
X-Frame-Options 
X-Content-Type-Options 
Referrer-Policy 
Permissions-Policy

I found the below code on Google and added the same in /etc/apache2/apache2.conf file

<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        Order Allow,Deny
        Allow from all
       Header set Access-Control-Allow-Origin "*"
       Header set Access-Control-Allow-Credentials true
       Header set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
       Header set Access-Control-Max-Age "1000"
       Header set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
</Directory>

After adding the above code I am getting below error

sudo service apache2 restart
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.

I have scanned my website in this URL: https://securityheaders.com/, and it shows an F result. here is the result link

I have to solve those issues, so I researched Google and found the header code to add to the Apache config file. so I have added the same code and got an error...

John Hanley avatar
in flag
Why are you playing with CORS? You have serious configuration problems to solve long before you can implement CORS. The first thing I would do is enable the firewall and prevent all public access to that server or turn if off and start over. If you have not been hacked already, you are a prime target. Warning: your screenshot shows your public IP address.
user9437856 avatar
ne flag
@JohnHanley, removed ip address, Thank you
John Hanley avatar
in flag
You edited the post. That does not remove the IP address from Stack Overflow. Almost everyone can see post edits.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.