V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
coolair
V2EX  ›  问与答

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

  •  
  •   coolair · Oct 31, 2018 · 884 views
    This topic created in 2734 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   ·   820 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 20:46 · PVG 04:46 · LAX 13:46 · JFK 16:46
    ♥ Do have faith in what you're doing.