Admin panel bundlers | Strapi 5 Documentation has details on how to add to the vite.config.js/ts file. There should already be an example file in your project in the src/admin
directory. Rename it from vite.config.example.ts
(or js) to vite.config.ts
and then replace the existing example config with an entry for server.allowedHosts
like you see in the error message.
My entire config (I’m using TypeScript) now looks like:
import { mergeConfig, type UserConfig } from 'vite';
export default (config: UserConfig) => {
// Important: always return the modified config
return mergeConfig(config, {
server: {
allowedHosts: true,
},
});
};
I didn’t see a need for this feature, so I set the value to true
, which allows everything. You could replace the boolean with a string containing the value you want to allow.