资源解释为样式表,但在AngularJS中使用MIME类型text / html进行传输 [英] Resource interpreted as Stylesheet but transferred with MIME type text/html in AngularJS
问题描述
有一个有角度的应用程序:
Have an angular application:
这是我的index.html页面的一部分:
This is part of my index.html page:
<!DOCTYPE html>
<html lang="en" ng-app="ReApp">
<head>
<meta charset="UTF-8">
<title>REApp</title>
<link rel="stylesheet" href="./lib/bootstrap/dist/css/bootstrap.min.css">
<script src="./lib/angular/angular.min.js"></script>
</head>
<body></body>
</html>
这是我的server.js(起点)的一部分:
This is part of my server.js(start point):
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public'));
app.use('/api', api);
app.get('*', function(req, res){
res.sendFile(__dirname + '/public/app/views/index.html');
});
问题是:当我有一条路线(localhost:3000 / first)时,一切正常。当我有类似的路由:localhost:3000 /第一/第二,我有一个错误资源解释为样式表,但转移MIME类型text / html。在终端我得到请求 - 第一/第二/ lib / angular / angular.min.js。当然我没有这个链接。谁知道如何在undex.html中设置此链接的起始页?
Problem is: when i have one route (localhost:3000/first) everything working. When i have route something like that: localhost:3000/first/second, i have an error "Resource interpreted as Stylesheet but transferred with MIME type text/html". In the terminal i have get request - first/second/lib/angular/angular.min.js. Of course i don't have that link. May who knows how to set a start page for this links in undex.html?
推荐答案
要解决此问题,您只需要do将< base href =/>
元素置于< title>
元素的正下方 index.html
页面的头部分。
To fix this issue all you have to do is place the <base href="/">
element just below the <title>
element in the head section of index.html
page.
这篇关于资源解释为样式表,但在AngularJS中使用MIME类型text / html进行传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!