url - GitHub pages and absolute paths - Stack Overflow

admin2025-04-16  2

when I use vite build, and use python3 -m http.server it run successfully. but deploy to Github Page (Project site), it fails to solve absolute path.

<script type="module" crossorigin src="/assets/index-BbwXgWnI.js"></script>

when I use vite build, and use python3 -m http.server it run successfully. but deploy to Github Page (Project site), it fails to solve absolute path.

<script type="module" crossorigin src="/assets/index-BbwXgWnI.js"></script>
Share Improve this question edited Feb 4 at 9:15 illusory0x0 asked Feb 3 at 16:29 illusory0x0illusory0x0 211 silver badge5 bronze badges 4
  • i think there is different question, i still can't use absolute path, just replace with relative path. – illusory0x0 Commented Feb 3 at 16:34
  • relative work, absolute didn't – illusory0x0 Commented Feb 3 at 16:39
  • here is a similar questionhttps://stackoverflow.com/questions/79208560/github-pages-with-vite-and-react-absolute-path-issue-for-javascript-rendering/79408482#79408482 – illusory0x0 Commented Feb 3 at 16:41
  • It matters if the page is a user/organization page, or a project page, but you don't show that. – Benjamin W. Commented Feb 3 at 18:43
Add a comment  | 

1 Answer 1

Reset to default 1

I found a solution for this use relative path

-    <script type="module" crossorigin src="/assets/index-BbwXgWnI.js"></script>
-    <link rel="stylesheet" crossorigin href="/assets/index-D9dz9LQE.css">
+    <script type="module" crossorigin src="assets/index-BbwXgWnI.js"></script>
+    <link rel="stylesheet" crossorigin href="assets/index-D9dz9LQE.css">

here is a similar question github pages and relative paths, but I think this question is out of date. Github Page can solve relative paths successfully. without any additional configuration.

转载请注明原文地址:http://www.anycun.com/QandA/1744761603a87248.html