简体   繁体   中英

pushing vite reactjs build on GitHub pages gives 404 on build files

i have a reactjs website using vitejs when i compile it using npm run build it generates the compiled site inside dist folder, when i publish the content to this folder i encounter a

Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'.

and serval

GET https://brijrajparmar27.github.io/assets/index.d12487b2.js net::ERR_ABORTED 404

here what i find odd is that if you check the url in above error its trying to find the .js file inside brijrajparmar27.github.io/assets/ shouldn't it be inside https://brijrajparmar27.github.io/[Repo-Name]/assets ?

it still works on my localhost though somehow.

after looking at this i added the [Repo-name]/ manually at the beginning of link tags of compiled index.html file in dist folder, on hosting that i got

GET https://brijrajparmar27.github.io/Atmosphere/Atmosphere/assets/vendor.95b2f1d7.js net::ERR_ABORTED 404

repo name is listed twice.

It seems that vite build defaults base to single "/" https://vitejs.dev/config/#base

I've fixed issue with incorrect request URL by changing build script in package.json to:

"build": "vite build --base=./"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM