skip to Main Content

I am deployed my branch using gh-pages. and it shows as successful. But when i open the page, html loaded as per my expectation. but source files from assets folder throws error as 404.

I have added "private": false, in my package.json and my browser root is updated like:

import React from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import App from "./App.tsx";
import "./index.css";

ReactDOM.createRoot(document.getElementById("root")!).render(
  <React.StrictMode>
    <BrowserRouter basename={process.env.PUBLIC_URL}>
      <App />
    </BrowserRouter>
  </React.StrictMode>
);

but still getting error as:

error i get

not able to understand the exact issue.

2

Answers


  1. Chosen as BEST ANSWER

    Finally I updated my config like this:

    export default defineConfig({
      base: "https://3gwebtrain.github.io/gitaction/",
      plugins: [react()],
    });
    

    works fine for me. thanks


  2. If name of the repo doesn’t follow the format of <username>.github.io, then the site will be deployed to <username>.github.io/<your_repo_name>.

    It seems that https://3gwebtrain.github.io/gitaction/ requested /assets/index-d7679c67.js instead of /gitaction/assets/index-d7679c67.js.

    To resolve this, you can try:

    // vite.config.ts
    import { defineConfig } from 'vite';
    import react from '@vitejs/plugin-react';
    
    export default defineConfig({
      plugins: [react()],
      base: '/gitaction/',
    });
    

    demo

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search