using baseUrl affects the path to my assets

不羁的心 提交于 2019-12-23 15:24:56

问题


I'm integrating an ember-cli app inside my main site which will be accessible at url http://host/faq/....ember...routes

So I added baseUrl: /faq/ to my ember

config/environment.js

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'faq',
    environment: environment,
    baseURL: '/faq/',
    locationType: 'hash',

The problem: While developing in my ember-cli environment with ember server my assets such as (SVG, FONTS and IMAGES) are giving me a NOT FOUND now.

For example: http://host/assets/images/bg.png gives me a not found it now expects http://host/faq/assets/images/bg.png. Why is this happening?


回答1:


I had the same problem with this project: Ember-Material-Navigation

I fixed this issue by defining a baseUrl variable in my main sass file and concatenating to all external urls.

$baseUrl: "/faq/";
@include font-face("Font Name", font-files($baseUrl + "/dir/font.ttf"));

However, this only works if you are using sass.




回答2:


If you want to serve assets from the root, leave base url as: baseURL: '/'.

Then, to customize the urls for your ember app, configure rootURL on the Router instance (app/router.js): rootURL: '/faq/'

http://emberjs.com/guides/routing/#toc_specifying-a-root-url



来源:https://stackoverflow.com/questions/26691204/using-baseurl-affects-the-path-to-my-assets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!