admin管理员组文章数量:1410717
So I have a 200 rewrite from domain1/abc/ to my react app hosted on domain2/<*>
The app is hosted on AWS Amplify and uses the following config:
Source address Target address Type
/abc/<*> /<*> 200 (Rewrite)
/<*> /index.html 404 (Rewrite)
In my vite.config.js
i defined the base as such:
export default defineConfig({
base: '/abc/',
// ...
})
In my react router, I added /abc/
:
<Routes>
<Route
path="/abc"
element={<ABComponent receivedFailedMessages={setFailedMessages} startRecovery={startRecovery} />}
/>
<Route path="*" element={<NotFound />} />
When trying to visit domain1/abc
I get the following error and the page doesn't load correctly (also goes for css and such):
Loading module from “.js” was blocked because of a disallowed MIME type (“text/html”).
When visiting domain2 the assets are served from /abc/assets
instead, but I still get the same error.
Build command for AWS deployments:
"build": "vite build --config vite.config.js"
Base dir in amplify.yml:
artifacts:
baseDirectory: dist
Built index.html contains /abc/
for linked js and css:
<!doctype html>
<html lang="en">
<head>
// ...
<script type="module" crossorigin src="/abc/assets/index-lZ-hm7W7.js"></script>
<link rel="stylesheet" crossorigin href="/abc/assets/index-9of53dkd.css">
</head>
// ...
</body>
</html>
I've tried removing the base URL, or setting it to blank, changing redirect options in Amplify (source to /abc/<*>), changing router to serve /
instead of /abc
but nothing seems to work.
Removing base then loading the page on domain2/
loads the page, but the reverse proxy doesn't work, same error.
At this point I'm out of ideas, especially since this setup used to work a couple months ago without issue (base /abc and rewrite configured as above)
Expected result it the page loads normally from domain1/abc
Edit:
It looks like there is something wrong with the reverse proxy setup
When visiting domain1/abc
it serves the index.html from the domain1 app, which means the assets have improper paths, and when visiting domain2
it serves the index.html from domain2.
本文标签: reactjsAWS Amplify redirect disallowed MIME type (“texthtml”)Stack Overflow
版权声明:本文标题:reactjs - AWS Amplify redirect disallowed MIME type (“texthtml”) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744818146a2626822.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论