最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Strapi - Blocked request - add domain to `server.allowedHosts` in vite.config.js - Stack Overflow

programmeradmin0浏览0评论

Blocked request. This host ("xx.xxxxx.xx") is not allowed. To allow this host, add "xx.xxxxx.xx" to server.allowedHosts in vite.config.js.

Blocked request. This host ("xx.xxxxx.xx") is not allowed. To allow this host, add "xx.xxxxx.xx" to server.allowedHosts in vite.config.js.

Share Improve this question asked Mar 19 at 2:33 gilzonmegilzonme 1712 silver badges9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

This is happening because of changes in Vite v6.1.0. One can fix this issue with following config changes inside src/admin/config/vite.config.js file (if you are using Strapi or your vite config file if using vite somewhere else). The file should look like as given below.

Note: Don't fet to build project again i.e. run yarn build or npm run build command.

const { mergeConfig } = require("vite");

module.exports = (config) => {
  // Important: always return the modified config
  const allowedHosts = ['localhost','127.0.0.1','youdomain'];
  return mergeConfig(config, {
    resolve: {
      alias: {
        "@": "/src",
      },
    },
   server: {
     allowedHosts
   }
  });
};
发布评论

评论列表(0)

  1. 暂无评论