V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
coolair
V2EX  ›  问与答

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

  •  
  •   coolair · 2018-10-31 17:53:57 +08:00 · 635 次点击
    这是一个创建于 2071 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 访问到该文件,请教下该如何配置?

    谢谢。

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2919 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 13:43 · PVG 21:43 · LAX 06:43 · JFK 09:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.