server.allowedHosts in vite.config.js

The solution that worked for me (in TS setup) was this (based on the following github issue: [Bug]: Strapi "host is not allowed" error · Issue #5443 · coollabsio/coolify · GitHub).

Add src/admin/vite.config.ts with these contents:

import { defineConfig, mergeConfig } from 'vite';

export default (config) => {
  return mergeConfig(config, defineConfig({
    resolve: {
      alias: {
        '@': '/src',
      },
    },
    server: {
      allowedHosts: true
    }
  }));
};

Then rebuild if needed and restart Strapi. I’m using Strapi v5.12.4.