You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to Make a Frontend Work on an Outdated Browser (Firefox 60.0, RHEL 7.7) or Chrome outdated version?
#1488
I used the GitHub search to find a similar question and didn't find it.
I searched in the documentation/README.
I already searched in Google "How to do X" and didn't find any information.
I already read and followed all the tutorial in the docs/README and didn't find an answer.
Commit to Help
I commit to help with one of those options 👆
Example Code
//----------------------------------------------> vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { TanStackRouterVite } from "@tanstack/router-vite-plugin";
import legacy from "@vitejs/plugin-legacy";
export default defineConfig({
plugins: [
react(),
TanStackRouterVite(),
legacy({
targets: [
"ie >= 11", // Internet Explorer 11+
"firefox >= 40", // Firefox 40+
"chrome >= 39", // Chrome 39+ (similar era)
"safari >= 9", // Safari 9+ (2015)
],
modernPolyfills: true, // Enables automatic modern API polyfills
additionalLegacyPolyfills: [
"regenerator-runtime/runtime", // For async/await support
"core-js/stable", // Provides missing ES6+ methods
"whatwg-fetch", // Polyfills fetch() for old browsers
],
}),
],
build: {
target: "es5", // Transpile to ES5 for full legacy support
},
});
//----------------------------------------------> main.tsx
// ✅ Add these polyfills at the top for legacy browser support
import "core-js/stable"; // Ensures ES6+ features work in older browsers
import "regenerator-runtime/runtime"; // Provides async/await support
import "whatwg-fetch"; // Polyfills fetch() for older browsers
// rest of updated code of main.tsx
Description
I have containerized my application and exported the following Docker images:
adminer
traefik
frontend
backend
db
I imported these images into an intranet server (RHEL 7.7, no internet access) and started them using docker compose up -d. Everything runs fine, and the backend reports a healthy status.
However, when I try to access the frontend using Firefox 60.0 (Quantum), the page doesn’t load properly. The browser console shows this error: SyntaxError: expected expression, got '?' in src='/assets/index-BQ5s1TCL.js'
This suggests that modern JavaScript syntax—like optional chaining (?.) or nullish coalescing (??)—is present in the built files, which Firefox 60.0 doesn’t support.
What I Tried
I updated my vite.config.ts to include @vitejs/plugin-legacy, which allowed the page to load, but the UI is completely broken and difficult to use.
My Question
How can I properly configure Vite (or adjust my build process) to ensure compatibility with outdated browsers without breaking the UI?
Any suggestions on Vite settings, Babel configuration, or alternative solutions would be greatly appreciated.
Operating System
Other
Operating System Details
I use Docker to run my application, so there are no OS dependency issues affecting the frontend.
Python Version
3.10
Additional Context
My goal is to make this template compatible with any outdated browsers, not just Firefox 60.0, so that it can run in environments with legacy systems.
The reason the page loads after adding @vitejs/plugin-legacy—but the UI is completely broken—comes down to two issues in your Vite configuration and CSS compatibility with Firefox 60 (released in 2018):
1. Remove build.target: "es5" and redundant manual polyfills
@vitejs/plugin-legacy automatically manages build.target and injects the required core-js and regenerator-runtime polyfills based on your targets list. Explicitly setting build.target: "es5" conflicts with Vite's esbuild minifier/bundler (which only supports down to es2015) and breaks the generated chunks. Also, avoid importing core-js/stable manually at the top of main.tsx when using plugin-legacy, as it duplicates polyfills and bloats the bundle.
Update your vite.config.ts to let plugin-legacy handle the targets cleanly:
import{defineConfig}from"vite";importreactfrom"@vitejs/plugin-react-swc";import{TanStackRouterVite}from"@tanstack/router-vite-plugin";importlegacyfrom"@vitejs/plugin-legacy";exportdefaultdefineConfig({plugins: [react(),TanStackRouterVite(),legacy({targets: ["firefox >= 60","chrome >= 60","not dead"],renderModernChunks: true,}),],build: {// Do NOT set target: "es5" here; plugin-legacy handles itcssTarget: "firefox60",},});
2. Why the UI is broken (CSS incompatibility in Firefox 60)
JavaScript polyfills only fix JS syntax (?., ??). However, full-stack-fastapi-template relies on Chakra UI, which uses modern CSS features (such as CSS Logical Properties like inset, margin-inline, newer Flexbox gap properties, and modern color functions) that Firefox 60 does not support.
To fix the layout in older browsers, you need PostCSS to downlevel modern CSS:
Install postcss-preset-env:
npm install -D postcss-preset-env
Create a postcss.config.js file in your frontend/ directory:
3. Practical Alternative for Air-Gapped / Legacy Intranets
Since your intranet server runs RHEL 7.7, note that Red Hat officially provides Firefox ESR (Extended Support Release) packages in the RHEL 7 repositories (such as Firefox 115 ESR or 128 ESR) via yum / offline RPM packages. Upgrading the client browser on the RHEL 7.7 machines to a modern Firefox ESR version is much more reliable than maintaining IE11/Firefox 60 polyfills for modern React/Chakra UI apps.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
First Check
Commit to Help
Example Code
Description
I have containerized my application and exported the following Docker images:
I imported these images into an intranet server (RHEL 7.7, no internet access) and started them using
docker compose up -d. Everything runs fine, and the backend reports a healthy status.However, when I try to access the frontend using Firefox 60.0 (Quantum), the page doesn’t load properly. The browser console shows this error:
SyntaxError: expected expression, got '?' in src='/assets/index-BQ5s1TCL.js'This suggests that modern JavaScript syntax—like optional chaining (?.) or nullish coalescing (??)—is present in the built files, which Firefox 60.0 doesn’t support.
What I Tried
I updated my
vite.config.tsto include@vitejs/plugin-legacy, which allowed the page to load, but the UI is completely broken and difficult to use.My Question
How can I properly configure Vite (or adjust my build process) to ensure compatibility with outdated browsers without breaking the UI?
Any suggestions on Vite settings, Babel configuration, or alternative solutions would be greatly appreciated.
Operating System
Other
Operating System Details
I use Docker to run my application, so there are no OS dependency issues affecting the frontend.
Python Version
3.10
Additional Context
My goal is to make this template compatible with any outdated browsers, not just Firefox 60.0, so that it can run in environments with legacy systems.
All reactions