Last active
February 8, 2018 09:06
-
-
Save jcsky/45e3b4ec99d60eab4fb07d4b4ae1ff23 to your computer and use it in GitHub Desktop.
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
# 原本的,會出現origin is not allowed by Access-Control-Allow-Origin 的錯誤 | |
config.middleware.insert_before 0, Rack::Cors do | |
allow do | |
origins /amazingtalker.com\z/ | |
resource '*', | |
headers: ['AtToken', 'AtLocale'], | |
methods: [:get, :post, :delete, :put, :patch, :options], | |
credentials: true | |
end | |
end | |
# 後來改成這樣,還是會出現origin is not allowed by Access-Control-Allow-Origin 的錯誤 | |
config.middleware.insert_before 0, Rack::Cors do | |
allow do | |
origins 'https://tw.amazingtalker.com', /amazingtalker.com\z/, 'tw.amazingtalker.com', 'en.amazingtalker.com' | |
resource '*', | |
headers: ['AtToken', 'AtLocale'], | |
methods: [:get, :post, :delete, :put, :patch, :options], | |
credentials: true | |
end | |
end |
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
[Error] Failed to load resource: Origin https://tw.amazingtalker.com is not allowed by Access-Control-Allow-Origin. (sign_in, line 0) | |
[Error] XMLHttpRequest cannot load https://api.amazingtalker.com/v1/user/sign_in. Origin https://tw.amazingtalker.com is not allowed by Access-Control-Allow-Origin. | |
[Error] Unrecognized Content-Security-Policy directive ‘base-uri’. |
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
# using gem 'rack-cors', :require => 'rack/cors' | |
# set debug: true, logger: Rails.logger | |
D, [2018-02-08T16:54:34.796915 #32523] DEBUG -- : Preflight Headers: | |
Content-Type: text/plain | |
D, [2018-02-08T16:54:34.797322 #32501] DEBUG -- : Incoming Headers: | |
Origin: http://tw.staging.amazingtalker.com | |
Access-Control-Request-Method: GET | |
Access-Control-Request-Headers: atlocale,attoken | |
D, [2018-02-08T16:54:34.797396 #32501] DEBUG -- : Preflight Headers: | |
Content-Type: text/plain | |
D, [2018-02-08T16:54:34.797543 #32523] DEBUG -- : Incoming Headers: | |
Origin: http://tw.staging.amazingtalker.com | |
Access-Control-Request-Method: GET | |
Access-Control-Request-Headers: atlocale,attoken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nginx 會收到 api request 的 access log