Support » Networking WordPress » Receiving CORS Issue while trying to access files from same domain

  • is a wordpress site with a custom theme and has multi-site option enabled. The subdirectory /p2s7 is another WordPress site and also has a custom theme. It has a login feature which was working fine 2-3 days back. But since yesterday, it is throwing CORS issue while trying to validate the login credentials. This validation is done by a file at location http://parent-site/child-site/location/file.php. As you would notice, the domain is same.. there is no issue of HTTP vs HTTPS and also the port remains unchanged (checked it at parent site, child site and even in the program which is being called for validation.).

    Error shown in console log:
    Access to XMLHttpRequest at ‘http://parent-site/sub-directory/location/file.php’ from origin ‘http://parent-site’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

    POST http://parent-site/sub-directory/location/file.php net::ERR_FAILED 200

    • This topic was modified 3 weeks, 4 days ago by James Huff. Reason: moved to Networking WordPress since this is a multisite issue and redundant link removed

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m not sure why there’s a CORS issue. There isn’t normally any CORS header sent since everything is normally same origin. There may be extra scrutiny for XMLHttp requests?

    Regardless of the reason, probably the simplest solution is to have WP send the header that’s expected. This can be done by hooking the “wp_headers” filter and adding any additional headers you want sent to the ones that WP sends by default.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.