Access-Control-Allow-Origin: 500 Internal Error
Asked Answered
B

2

6

So I am trying to have siteA do a jquery .load of some content on siteB. In doing this, im getting the Access-Control-Allow-Origin Error. So on siteB, I placed a .htaccess file that should allow siteA to be able to grab content from it. I am running into some trouble with this. I know the .htaccess file is being access because it is getting a 500 Internal Error when the page tries to load and i have content in the .htaccess file.

In the .htaccess file i have tried: Access-Control-Allow-Origin: * and: Access-Control-Allow-Origin: "*"

but both give the 500 error. I have also tried: Access-Control-Allow-Origin: *

This doesn't give the 500 error, so it must be coming back as false. I am not really sure what to do at this point. its possible i might be formatting the .htaccess file wrong or something, but i think it may have to do with mod_headers not being enabled.

In Logs: Invalid command 'Access-Control-Allow-Origin:', perhaps misspelled or defined by a module not included in the server configuration

Both sites are running through 10.8 Server.app, so its a little different from a normal Apache install which is making it a little difficult. Any help would be greatly appreciated! Thanks in advance!

Bedstraw answered 6/8, 2013 at 16:37 Comment(5)
500 can mean your .htaccess is bad.Radiancy
I don't think Access-Control-Allow-Origin is causing your 500 errors. Check your server error logs to see what the reason for the 500 is.Steeve
just added the log to the orig question. When i comment out the Access-Control command, the site loads, when it is uncommented, it errors. That line is the only line in the .htaccessBedstraw
"Invalid command Access-Control-Allow-Origin" would lead me that you have the wrong syntax in the .htaccess file. Can you post the .htaccess file with the header line included?Steeve
Sorry, first .htaccess file i have done. I didn't know i needed a header. The commands i had above was all the text from inside the .htaccess file. I just changed it to "Header add Access-Control-Allow-Origin "*"" and i think that is working now. Not seeing the errors anymore. Thanks for the help Steven!!Bedstraw
V
11

I was just having the same issue, error 500 when I used:

Header add Access-Control-Allow-Origin "*"

It was due to a missing module , mod_headers , I just had to run on my server:

sudo a2enmod headers

as found here

but i think you may need to edit manually .conf on OSX and uncomment the line:

#LoadModule headers_module modules/mod_headers.so
Vertebra answered 29/7, 2015 at 2:3 Comment(0)
S
1

In my case, I have copied code from somewhere, which is having some spaces, that was the reason for internal server error.

I was using

header("Access-Control-Allow-Origin : *");

We should write

header("Access-Control-Allow-Origin:*");

I have just removed spaces between Origin, :, and *

Try writing the code instead of copy, that may help.

Strength answered 17/9, 2018 at 8:10 Comment(1)
Specially the gap should not between "Access-Control-Allow-Origin" and ":"Strength

© 2022 - 2024 — McMap. All rights reserved.