Deploying a modern JavaScript web application to a traditional shared hosting environment often introduces unexpected friction. Recently, while migrating a website built with Vite and React from manual file uploads to a continuous deployment pipeline using GitHub Actions and Hostinger, we hit a wall of common infrastructure pitfalls: broken DNS zones, strict browser MIME type errors, nested folder loops, and firewall data socket resets (ECONNRESET).
If you are trying to configure a modern web application deployment over traditional FTP/FTPS while keeping your domain email routing active and completely untouched, here is exactly what went wrong and how we engineered a pipeline to fix it.
THE ARCHITECTURE
The Core Challenge & Architecture Goal
VS Code environment tracking a modern web framework codebase bundled via npm run build.
Hostinger shared hosting handling both web asset storage (public_html) and custom business email addresses.
Automate deployments so pushing code to GitHub compiles and transfers production assets to the server root, without modifying active MX/TXT records or breaking custom email accounts.
01 / DNS CONFIGURATION
The Broken DNS & getaddrinfo ENOTFOUND Failure
Initially, connecting the repository directly inside Hostinger's dashboard reset the domain's DNS zone configuration back to hosting defaults, severing custom registrar connections. When switching to an automated pipeline, assigning standard domain addresses (like ://example.com) or including protocol prefixes (like ftp://194.xxx.xx.xx) inside the FTP_SERVER GitHub secret triggered immediate network lookup exceptions.
Bypass the Domain Name System during automated pipeline workflows. Fetch the raw numeric FTP IP address from your host provider dashboard and feed it directly into the GitHub repository secret without text prefixes or trailing slashes:
Incorrect: ftp://123.45.67.89Correct: 123.45.67.8902 / MIME TYPES
The Infamous White Screen: Strict MIME Type Checking
After a successful file transfer, loading the webpage returned a blank white screen. The browser console threw a fatal spec error:
“Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of 'text/plain'. Strict MIME type checking is enforced...”
Traditional Apache servers do not natively know how to serve compiled modern ES module files (.js, .mjs) produced by tools like Vite, forcing them to download as plain text. Browsers reject these scripts on sight.
Add an explicit header enforcement file to your build template. Place a .htaccess file inside your project's public/ folder so your compiler copies it into the final production bundle, then instruct Apache to output the correct content headers.
📄 View the .htaccess configuration
<IfModule mod_mime.c>
AddType application/javascript .js
AddType application/javascript .mjs
</IfModule>
<FilesMatch "\.(js|mjs)quot;>
Header set Content-Type "application/javascript"
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>03 / CONNECTION STABILITY
The Shared Hosting Firewall Block: ECONNRESET
When pushing dozens of compiled assets simultaneously, the deployment abruptly failed mid-upload with a “Client is closed because read ECONNRESET” exception. Shared hosting accounts enforce rate limits on port interactions; rapid, unencrypted concurrent connections can look like a cyberattack, triggering an automated server-side connection drop.
Use explicit TLS-encrypted FTPS and allocate longer internal network execution times to allow the server time to safely parse individual file chunks.
04 / SERVER PATHS
The Infinite Subfolder Loop: public_html/public_html
Configuring the server directory path to /public_html/ caused a duplicate nested directory to appear on the server. Hostinger's default FTP configurations can root user logins inside the site's target folder. Telling the script to look for public_html/ then appends a new folder inside the one you're already in.
Remove the old state history tracker file (.ftp-deploy-sync-state.json) from the file manager to clear old sync records. Then configure the pipeline to deploy directly into the current authenticated root path (./) using a fresh custom sync signature name.
THE WORKFLOW
The Complete Solution: Production-Ready GitHub Workflow
Here is the final GitHub Actions workflow configuration, combining a build, artifact archive, and FTPS deployment. It uses a flat target path and a separate state file for deployment tracking.
🚀 View the main.yml workflow
name: Production - Build and Deploy App
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js Environment
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Project Dependencies
run: npm ci
- name: Compile Production Build
run: npm run build
- name: Archive Production Build Artifacts
uses: actions/upload-artifact@v4
with:
name: site-production-bundle
path: dist/
retention-days: 7
- name: Sync Production Bundle to Hostinger via Secured FTPS
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./dist/
server-dir: ./
port: 21
protocol: ftps
security: loose
state-name: .clean-production-sync.json
timeout: 120000TROUBLESHOOTING
Automated Deployment Checklist
If your pipeline encounters friction or the live environment triggers unexpected behavior, run these sanity checks sequentially.
📡 Pipeline connection failures
- Clean the server secret: Verify
FTP_SERVERdoes not contain prefixes likeftp://or paths like/public_html. Use a raw numeric IP address or bare domain. - Verify account identifiers: Ensure
FTP_USERNAMEincludes your host's account system prefix (for example,u123456789.username), not just your custom profile name. - Confirm firewall settings: If logs show an immediate
ECONNRESETduring folder setup, verify the protocol is explicitly set toftpsand the timeout is raised to120000.
📂 File and directory path alignment
- Locate build outputs: Run
npm run buildlocally. If your framework outputs to a folder other thandist(such asbuildorout), updatelocal-dirto match. - Eliminate subfolder loops: If the live site returns a 404 or files land in a nested folder, remove the redundant folder in File Manager and set
server-dirto./. - Purge cache states: If paths change but transfers still behave incorrectly, delete old tracking signatures such as
.ftp-deploy-sync-state.jsonfrom host storage and use a freshstate-name.
🌐 Live browser render anomalies
- Relocate server directives: Keep
.htaccessinside the local sourcepublic/directory so it is copied into the production build. - Test in isolation: If files upload successfully but changes do not appear, open an Incognito or Private window to bypass stale browser or edge network caching.
