{"id":36642,"date":"2024-09-30T06:14:32","date_gmt":"2024-09-30T06:14:32","guid":{"rendered":"https:\/\/www.wpstaq.com?post_type=knowledgebase&#038;p=36642"},"modified":"2024-09-30T07:00:39","modified_gmt":"2024-09-30T07:00:39","slug":"how-to-fix-access-control-allow-origin-issue","status":"publish","type":"knowledgebase","link":"https:\/\/www.wpstaq.com\/sg\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/","title":{"rendered":"How to fix Access-Control-Allow-Origin issue"},"content":{"rendered":"<p>Are you seeing this type of error message?<\/p>\n<p><code>Access to resource at 'https:\/\/www.example.com\/path\/to\/resource' from origin 'https:\/\/example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.<\/code><\/p>\n<p>This error indicates a mismatch between the domain serving the resources and the domain from which the content is being accessed. In this guide, we&#8217;ll explain how to resolve this issue within your WordPress site hosted on Staq.<\/p>\n<h2>Understanding the Issue<\/h2>\n<p>In this example, the URL `https:\/\/www.example.com` is where the resources (such as fonts, images, or scripts) are being served from, while the primary domain is set to `https:\/\/example.com`. This mismatch is causing the browser to block the resources due to the <strong>No &#8216;Access-Control-Allow-Origin&#8217;<\/strong> error.<\/p>\n<h2>Steps to Resolve the CORS Issue<\/h2>\n<h3>1. Check if the PRIMARY Domain is Correct<\/h3>\n<p>First, log into the site&#8217;s <strong>Staq Panel<\/strong> and go to <strong>Domains<\/strong>. Verify that the <strong>PRIMARY domain<\/strong> is set to `https:\/\/example.com`.<br \/>\nIf the primary domain is correct, but the resources are being served from https:\/\/www.example.com, the mismatch will cause the CORS issue.<\/p>\n<h3>2. Update Theme Files<\/h3>\n<p>If your primary domain is correct, check your theme files for any hard-coded URLs that reference `https:\/\/www.example.com`. You may need to change these to match the primary domain, `https:\/\/example.com`.<\/p>\n<h3>3. Clear Theme or Performance Cache<\/h3>\n<p>If updating the theme files doesn&#8217;t resolve the issue, it might be due to cached settings in your theme or performance caching plugins. Clear your website\u2019s cache (via your theme settings or any caching plugins) to ensure that the correct URLs are being served.<\/p>\n<h3>4. Perform a Database Search and Replace<\/h3>\n<p>If the issue persists, you may need to perform a <strong>search and replace<\/strong> in your WordPress database to ensure all instances of `https:\/\/www.example.com` are replaced with the correct primary domain, `https:\/\/example.com`.<br \/>\nRefer to our guide on how to perform a database search and replace: <a href=\"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-do-a-search-replace\/\">How to Do a Search\/Replace<\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>The <strong>Access-Control-Allow-Origin<\/strong> issue can arise due to mismatched domains when serving resources. By ensuring the correct primary domain is set and making sure your theme files, cached settings, or database values are updated accordingly, you can resolve this error. If you need further assistance, feel free to contact our support team.<\/p>\n","protected":false},"featured_media":0,"parent":0,"template":"","class_list":["post-36642","knowledgebase","type-knowledgebase","status-publish","hentry","categories-server-errors"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to fix Access-Control-Allow-Origin issue - Managed Hosting Platform for WordPress<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to fix Access-Control-Allow-Origin issue - Managed Hosting Platform for WordPress\" \/>\n<meta property=\"og:description\" content=\"Are you seeing this type of error message? Access to resource at &#8216;https:\/\/www.example.com\/path\/to\/resource&#8217; from origin &#8216;https:\/\/example.com&#8217; has been blocked by CORS policy: No &#8216;Access-Control-Allow-Origin&#8217; header is present on the requested resource. This error indicates a mismatch between the domain serving the resources and the domain from which the content is being accessed. In this guide,&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/\" \/>\n<meta property=\"og:site_name\" content=\"Managed Hosting Platform for WordPress\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/staqhosting\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-30T07:00:39+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/how-to-fix-access-control-allow-origin-issue\\\/\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/how-to-fix-access-control-allow-origin-issue\\\/\",\"name\":\"How to fix Access-Control-Allow-Origin issue - Managed Hosting Platform for WordPress\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#website\"},\"datePublished\":\"2024-09-30T06:14:32+00:00\",\"dateModified\":\"2024-09-30T07:00:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/how-to-fix-access-control-allow-origin-issue\\\/#breadcrumb\"},\"inLanguage\":\"en-sg\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/how-to-fix-access-control-allow-origin-issue\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/how-to-fix-access-control-allow-origin-issue\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.wpstaq.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to fix Access-Control-Allow-Origin issue\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#website\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/\",\"name\":\"Managed Hosting Platform for WordPress\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.wpstaq.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-sg\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#organization\",\"name\":\"Staq\",\"alternateName\":\"WPStaq\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-sg\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/cropped-LogoNoText.png\",\"contentUrl\":\"https:\\\/\\\/www.wpstaq.com\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/cropped-LogoNoText.png\",\"width\":512,\"height\":512,\"caption\":\"Staq\"},\"image\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/staqhosting\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/wpstaq\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to fix Access-Control-Allow-Origin issue - Managed Hosting Platform for WordPress","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/","og_locale":"en_US","og_type":"article","og_title":"How to fix Access-Control-Allow-Origin issue - Managed Hosting Platform for WordPress","og_description":"Are you seeing this type of error message? Access to resource at &#8216;https:\/\/www.example.com\/path\/to\/resource&#8217; from origin &#8216;https:\/\/example.com&#8217; has been blocked by CORS policy: No &#8216;Access-Control-Allow-Origin&#8217; header is present on the requested resource. This error indicates a mismatch between the domain serving the resources and the domain from which the content is being accessed. In this guide,&hellip;","og_url":"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/","og_site_name":"Managed Hosting Platform for WordPress","article_publisher":"https:\/\/www.facebook.com\/staqhosting\/","article_modified_time":"2024-09-30T07:00:39+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/","url":"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/","name":"How to fix Access-Control-Allow-Origin issue - Managed Hosting Platform for WordPress","isPartOf":{"@id":"https:\/\/www.wpstaq.com\/#website"},"datePublished":"2024-09-30T06:14:32+00:00","dateModified":"2024-09-30T07:00:39+00:00","breadcrumb":{"@id":"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/#breadcrumb"},"inLanguage":"en-sg","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wpstaq.com\/knowledgebase\/how-to-fix-access-control-allow-origin-issue\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.wpstaq.com\/"},{"@type":"ListItem","position":2,"name":"How to fix Access-Control-Allow-Origin issue"}]},{"@type":"WebSite","@id":"https:\/\/www.wpstaq.com\/#website","url":"https:\/\/www.wpstaq.com\/","name":"Managed Hosting Platform for WordPress","description":"","publisher":{"@id":"https:\/\/www.wpstaq.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wpstaq.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-sg"},{"@type":"Organization","@id":"https:\/\/www.wpstaq.com\/#organization","name":"Staq","alternateName":"WPStaq","url":"https:\/\/www.wpstaq.com\/","logo":{"@type":"ImageObject","inLanguage":"en-sg","@id":"https:\/\/www.wpstaq.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2023\/05\/cropped-LogoNoText.png","contentUrl":"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2023\/05\/cropped-LogoNoText.png","width":512,"height":512,"caption":"Staq"},"image":{"@id":"https:\/\/www.wpstaq.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/staqhosting\/","https:\/\/www.linkedin.com\/company\/wpstaq"]}]}},"_links":{"self":[{"href":"https:\/\/www.wpstaq.com\/sg\/wp-json\/wp\/v2\/knowledgebase\/36642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wpstaq.com\/sg\/wp-json\/wp\/v2\/knowledgebase"}],"about":[{"href":"https:\/\/www.wpstaq.com\/sg\/wp-json\/wp\/v2\/types\/knowledgebase"}],"wp:attachment":[{"href":"https:\/\/www.wpstaq.com\/sg\/wp-json\/wp\/v2\/media?parent=36642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}