.css 未加载,因为其 MIME 类型“text/html"不是“text/css".和 SyntaxError: 预期的表达式,得到 '<' [英] .css was not loaded because its MIME type, “text/html”, is not “text/css”. and SyntaxError: expected expression, got '<'
问题描述
在本地主机上一切正常.这就是为什么不能经常测试的原因.S3 自动构建仅针对 xdomain.com/callback/google/signup 等多个斜线路径创建 text/html 而不是 text/css 并面临以下错误:
Everything's working fine in localhost. That's why can't test frequently. S3 auto build creating text/html instead of text/css only for multiple slashed path like xdomain.com/callback/google/signup and facing the error below:
样式表 https://xdomain.com/callback/google/signup/static/css/2.40dccbaa.chunk.css 未加载,因为其 MIME 类型text/html"不是text/css".
The stylesheet https://xdomain.com/callback/google/signup/static/css/2.40dccbaa.chunk.css was not loaded because its MIME type, "text/html", is not "text/css".
与此页面的 js 文件相同,显示 SyntaxError: expected expression, got '<'错误.
same for this page's js file showing SyntaxError: expected expression, got '<' error.
所有其他路径,如 https://xdomain.com/home 或 https://xdomain.com/dashboard 工作正常.
all other path like https://xdomain.com/home or https://xdomain.com/dashboard working fine.
我无法修复如何为多个斜线路径 url 页面解决此 css 或 js 路径.
I can't fix how to solve this css or js path for multiple slashed path url page.
import "./GoogleSignupCallback.scss"; // that's how i import scss file in different pages.
App.js 文件
import React from "react";
import {
BrowserRouter as Router,
Switch,
Route,
Redirect,
} from "react-router-dom";
import "./scss/common.scss";
import Home from "./views/Home";
import GoogleSingupCallback from "./views/SNS/GoogleSignupCallback/index";
import Cms from "./views/Cms/index";
const App = () => {
return (
<Router>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/cms" component={Cms} />
<Route exact path="/callback/google/signup" component={GoogleSingupCallback} />
<Redirect to="/" />
</Switch>
</Router>
);
};
export default App;
请帮忙.
推荐答案
你有主页"吗?列在你的 package.json 中?
Do you have a "homepage" listed in you package.json?
尝试将其删除或将其设置为/".
Try to remove it or set it to "/".
这篇关于.css 未加载,因为其 MIME 类型“text/html"不是“text/css".和 SyntaxError: 预期的表达式,得到 '<'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!