我已經轉載了這個。當您使用不同的URL訪問網站並訪問相關資源時,可能會發生此錯誤。出於安全原因,瀏覽器允許從與您正在查看的頁面完全相同的主機訪問資源。
似乎您通過http://127.0.0.1:8000
訪問應用程序,但您已配置CubesViewer以通過http://localhost:8000
告訴客戶端訪問數據後端。雖然它是相同的IP地址,但它們是不同的字符串。
請嘗試訪問應用程序爲http://localhost:8000
。
如果您部署到不同的服務器,則需要調整設置。以下是相關的配置選項,現在更多的評論:
# Base Cubes Server URL.
# Your Cubes Server needs to be running and listening on this URL, and it needs
# to be accessible to clients of the application.
CUBESVIEWER_CUBES_URL="http://localhost:5000"
# CubesViewer Store backend URL. It should point to this application.
# Note that this must match the URL that you use to access the application,
# otherwise you may hit security issues. If you access your server
# via http://localhost:8000, use the same here. Note that 127.0.0.1 and
# 'localhost' are different strings for this purpose. (If you wish to accept
# requests from different URLs, you may need to add CORS support).
CUBESVIEWER_BACKEND_URL="http://localhost:8000/cubesviewer"
或者,你可以改變CUBESVIEWER_BACKEND_URL
到"http://127.0.0.1:8000/cubesviewer"
但我建議你使用主機名和這個不是IP地址。
最後,我還沒有測試CORS支持,但如果您想嘗試這種方法,請檢查this pull request。
啓用cors支持解決了我的問題..謝謝 –