coolair
V2EX  ›  问与答

请问下, flask 使用了 subdomain 后, css 中引用的字体文件,以及 require.js 配置文件中引用的 js 文件都变成 subdomain 开头的链接,导致不能访问,这个如何解决?

  •  
  •   coolair · Oct 31, 2018 · 929 views
    This topic created in 2758 days ago, the information mentioned may be changed or developed.
    app.static_url_path = '/static'
    app.static_folder = 'static'
    app.add_url_rule(app.static_url_path + '/<path:filename>',
                               endpoint='static',
                               view_func=app.send_static_file)
    

    按如上设置通过 url_for 引用的 static 文件可以正常访问,但是 css 中通过 src: url('../fonts/test.ttf') format('truetype');引用的字体就无法访问。

    因为如上引用走的是 subdomain 的链接,比如:a.test.com/static/fonts/test.ttf ,但是可以通过 test.com/static/fonts/test.ttf 访问到该文件,请教下该如何配置?

    谢谢。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2550 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 15:55 · PVG 23:55 · LAX 08:55 · JFK 11:55
    ♥ Do have faith in what you're doing.