Last active
July 27, 2018 21:16
-
-
Save NickDeckerDevs/8cfe80e1e2c44a9c6c305b9143f80a64 to your computer and use it in GitHub Desktop.
.htaccess addition to allow cross origin requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I advise using option 1 or two and only copying over the comments from where the option starts to the end of the </IfModule> tag | |
# To understand what is going on here is the documentation that I read to get this to work: https://httpd.apache.org/docs/2.4/mod/mod_headers.html | |
# Option 1 | |
# This is where you add your hubspot domain. If you are importing your wordpress templates into multiple domains, see option 2. | |
# | |
# Replace https://dev.domain.com below with the domain that HubSpot is on. If you are currently working on a dev domain | |
# or some sort of staging server, you will need to change the domain to what you see in the URL at the top when previewing. | |
# | |
<IfModule mod_headers.c> | |
Header add Access-Control-Allow-Origin "https://dev.domain.com" | |
Header add Access-Control-Allow-Methods: "GET" | |
</IfModule> | |
# Option 2 | |
# This will be the most difficult option for most developers to implement. | |
# | |
# Multiple Domains - make sure to escape the . (dot) - separate domains by | (pipe) | |
# In the example below we are allowing TWO domains to access your wordpress site | |
# https://offers.domain.com AND https://domain.hs-sites.com | |
# This may take some developers a few tries to get right. We will address this later. | |
<IfModule mod_headers.c> | |
SetEnvIf Origin "^http(s)?://(.+\.)?(offers\.domain\.com|domain\.hs-sites\.com)$" origin_is=$0 | |
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is | |
Header add Access-Control-Allow-Methods: "GET" | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment