[英]Node js with socket io application
我在.htaccess
包含了以下幾行:
#Header set Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"#
我可以在http://www.example.com上運行帶有 socket io 應用程序的節點 js,但是當我嘗試在https://www.example.com上運行時,我收到錯誤消息"Access-Control-Allow-Origin" header is present on the requested resource
。 我嘗試在 CentOS 上創建一個虛擬主機,托管在/etc/httpd/conf.d/httpd.conf
Apache Web 服務器上。 當我打開一個像 3000 這樣的非標准端口並監聽它時,我在運行“已在使用的端口”時收到錯誤消息。 我該怎么辦?
你應該在你的 node express 服務器上實現 cors !
https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
或者你可以嘗試為那個https://github.com/agrueneberg/Corser實現包
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.