无法加载资源:服务器以404()的状态响应 - react部署可以找到文件,而i18翻译
我在部署投资组合时遇到麻烦。 我使用i18-reactnext库来翻译代码,并且在开发服务器中一切正常,但是当我进行构建时,我会遇到错误。 我尝试在vercel中部署Git Hub页面,即使在预览中,我也会遇到相同的错误。
Failed to load resource: the server responded with a status of 404
import React from 'react';
import ReactDOM from 'react-dom/client';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import HttpApi from 'i18next-http-backend';
import App from './views/App';
import './reset.css';
import './index.css';
import 'bootstrap-icons/font/bootstrap-icons.css';
import 'flag-icon-css/css/flag-icons.min.css';
i18n
.use(initReactI18next)
.use(LanguageDetector)
.use(HttpApi)
.init({
supportedLngs: ['pt', 'en'],
fallbackLng: 'pt',
detection: {
order: ['cookie', 'localStorage', 'htmlTag', 'path', 'subdomain'],
caches: ['cookie'],
},
backend: {
loadPath: '../assets/locales/{{lng}}/translation.json',
},
});
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
I am having troubles deploying my portfolio.
I used the i18-reactnext library to translate the code and everything works fine in development server, but when i do the build i get the errors.
i tried deploying in git hub pages, in vercel and even in the preview i got the same errors.
Failed to load resource: the server responded with a status of 404
import React from 'react';
import ReactDOM from 'react-dom/client';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import HttpApi from 'i18next-http-backend';
import App from './views/App';
import './reset.css';
import './index.css';
import 'bootstrap-icons/font/bootstrap-icons.css';
import 'flag-icon-css/css/flag-icons.min.css';
i18n
.use(initReactI18next)
.use(LanguageDetector)
.use(HttpApi)
.init({
supportedLngs: ['pt', 'en'],
fallbackLng: 'pt',
detection: {
order: ['cookie', 'localStorage', 'htmlTag', 'path', 'subdomain'],
caches: ['cookie'],
},
backend: {
loadPath: '../assets/locales/{{lng}}/translation.json',
},
});
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论