You're encountering a 404 Not Found error for your React+Vite application's assets (index-vI4EDjyW.js, index-CIO3n2MM.css) when trying to load them from the IIS server. This is a common issue when hosting Vite-built static files on IIS, especially if the asset paths are not correctly resolved.
✅ Summary of Your Setup
- Frontend: React + Vite → built with
vite build → hosted on IIS
- Backend:
- Mostly Node.js
- One endpoint hits FastAPI
- Domain: Using a valid SSL certificate for
https://askpal.ai
- Issue: Assets like
.js and .css files are returning 404 errors.
🔍 Root Cause Analysis
The error:
GET https://askpal.ai/assets/index-vI4EDjyW.js net::ERR_ABORTED 404 (Not Found)
Means that the browser tried to fetch an asset from https://askpal.ai/assets/..., but it wasn't found on the server — i.e., the path is incorrect or IIS isn’t configured to serve those static files properly.
🛠️ Step-by-Step Fixes
✅ 1. Verify Build Output
Make sure you ran:
npm run build
This should generate a dist/ folder containing:
index.html
assets/ folder with .js, .css files
Double-check that all these files were copied to your IIS directory (e.g., C:\inetpub\wwwroot\yourapp).
✅ 2. Correct Base Path in Vite Config
If your app is hosted at a subpath like https://askpal.ai/myapp/, you need to configure Vite’s base option:
In vite.config.js:
export default defineConfig({
base: '/', // or '/myapp/' if deployed under a subdirectory
build: {
outDir: 'dist'
}
});
If it's served directly at the root (https://askpal.ai/), keep base: '/'.
✅ 3. Configure IIS to Serve Static Files
Ensure IIS is configured to:
- Serve static content
- Allow unknown file types (if needed)
Install Required Features:
On the VM, make sure the following IIS features are installed:
Enable-WindowsOptionalFeature -Online -FeatureName:IIS-StaticContent -All
Also ensure MIME types are correct so .js and .css files are recognized.
✅ 4. Check Web.config for Correct MIME Types
Sometimes .js or .css files aren't recognized by IIS unless explicitly allowed.
Create or update your web.config in the root of your IIS site:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".js" mimeType="application/javascript" />
<mimeMap fileExtension=".css" mimeType="text/css" />
</staticContent>
</system.webServer>
</configuration>
✅ 5. Set Correct MIME Types via IIS Manager
Alternatively:
- Open IIS Manager
- Go to your site
- Double-click MIME Types
- Ensure entries for:
.js → application/javascript
.css → text/css
Add them if they’re missing.
✅ 6. Fix URL Rewriting / SPA Routing
Since you're using React (SPA), you'll also want to redirect all routes to index.html. Otherwise, navigating directly to /about will return a 404.
Add this to your web.config:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
✅ 7. Check File Permissions on IIS
Ensure that the IIS user has read access to the folder where your dist/ files are located.
✅ 8. Test Locally First
Before deploying to IIS, test your dist/ folder locally using a simple static server:
npx serve dist
Then visit http://localhost:5000 and check if assets load.
🧪 Final Checklist
| Task | Status |
|---|
| Build files exist in IIS directory? | ✅ |
Correct base set in vite.config.js? | ✅ |
MIME types for .js, .css added? | ✅ |
SPA routing handled via web.config rewrite? | ✅ |
| Permissions on IIS folder allow read access? | ✅ |
📌 Bonus Tip: Use Developer Tools
Open DevTools > Network tab, look at:
- What path is being requested?
- Is the asset actually present on the server?
- Are there any redirects?
❓Still Stuck?
Let me know:
- The exact URL structure you're using (e.g.,
https://askpal.ai/ vs https://askpal.ai/app)
- How you deployed the files (copy manually? FTP? script?)
- Any custom
web.config rules you have
And I’ll give you a tailored fix!