bolt.diy: Blocked request. This host ("boltdiy.mydomain.no")

Describe the bug

The latest release v0.0.6 works and does not have this issue. Now I am getting this error, using the main branch:

Blocked request. This host (“boltdiy.mydomain.no”) is not allowed. To allow this host, add “boltdiy.mydomain.no” to server.allowedHosts in vite.config.js.

I run bolt.diy behind an nginx proxy using https and a valid certificate, I have tried to fix this based on the error message but cant get it to work. Downloaded the 0.0.6 release tar.gz and made a docker out of that which works perfectly. In the Dockerfile from the release source i did have to add: RUN npm install -g corepack@latest otherwise the build failed.

I’d imagine testing with localhost as hostnames when developing you wont see this error with vite, looks like others have the same issue looking at issues in vitejs on github, and for some downgrading to 6.0.8 fixes the problem.

Link to the Bolt URL that caused the error

https://boltdiy.mydomain.no

Steps to reproduce

Run bolt.diy behind a nginx proxy, here is my configuration, renamed my domain name:

Ottodev - Bolt.new - Bolt.diy

server { listen 443 ssl;

allow 0.0.0.0/0;
deny all;

ssl_certificate /etc/letsencrypt/live/mydomain.no/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mydomain.no/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

server_name   boltdiy.mydomain.no;
client_max_body_size 20m;

location / {
    proxy_pass         http://aisrv.mydomain.no:5173;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection "Upgrade";
    proxy_set_header   Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_buffering off;
    proxy_cache off;
    chunked_transfer_encoding off;

    proxy_set_header   X-Real-IP         $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;
}

if ( $host !~* ^(boltdiy\.mydomain\.no)$ ) {
        return 444;
}

}

Expected behavior

I expected it to work like it normally does.

Screen Recording / Screenshot

No response

Platform

  • Ubuntu 24.04 LTS
  • Browser: Chrome

Provider Used

No response

Model Used

No response

Additional context

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 15

Most upvoted comments

I had the same problem hosting it with a K3s ingress fronting it.

I went to my dockerhost and editted the vite.config.ts and added a “server” block between the define and build sections for the export defineConfig (around line 74 presently).

e.g.

export default defineConfig((config) => {
  return {
    define: {
      __COMMIT_HASH: JSON.stringify(gitInfo.commitHash),
      __GIT_BRANCH: JSON.stringify(gitInfo.branch),
      __GIT_COMMIT_TIME: JSON.stringify(gitInfo.commitTime),
      __GIT_AUTHOR: JSON.stringify(gitInfo.author),
      __GIT_EMAIL: JSON.stringify(gitInfo.email),
      __GIT_REMOTE_URL: JSON.stringify(gitInfo.remoteUrl),
      __GIT_REPO_NAME: JSON.stringify(gitInfo.repoName),
      __APP_VERSION: JSON.stringify(process.env.npm_package_version),
      __PKG_NAME: JSON.stringify(pkg.name),
      __PKG_DESCRIPTION: JSON.stringify(pkg.description),
      __PKG_LICENSE: JSON.stringify(pkg.license),
      __PKG_DEPENDENCIES: JSON.stringify(pkg.dependencies),
      __PKG_DEV_DEPENDENCIES: JSON.stringify(pkg.devDependencies),
      __PKG_PEER_DEPENDENCIES: JSON.stringify(pkg.peerDependencies),
      __PKG_OPTIONAL_DEPENDENCIES: JSON.stringify(pkg.optionalDependencies),
    },
    server: {
      host: true,
      allowedHosts: [
        'localhost',
        'boltdiy.mydomain.no'
      ],
    },

When i relaunched docker compose i was unblocked

Hi @johnberntsen, adding your domain as an allowed host in vite config should fix this.

server: {
  host: true,
  allowedHosts: [
    'localhost',
    'bolt.diy.mydomain.no'
  ]
}

It works, could probably add a .env setting like ‘REVERSE_PROXY_HOST’ and use that setting to adjust this on the fly too.

Vite actually already has __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS as an env var, it just needs to be added to the bolt dockerfile. https://vite.dev/config/server-options#server-allowedhosts

Hi @johnberntsen, adding your domain as an allowed host in vite config should fix this.

server: {
  host: true,
  allowedHosts: [
    'localhost',
    'bolt.diy.mydomain.no'
  ]
}

going to go ahead and close this issue as its now resolved, thanks.

how exactly is this resolved im getting the same error

see reply above: https://github.com/stackblitz-labs/bolt.diy/issues/1341#issuecomment-2671130057

Basically after this line in vite.config.ts:

     __PKG_OPTIONAL_DEPENDENCIES: JSON.stringify(pkg.optionalDependencies),
    },

COPY THIS and pay attention to indents.

    server: {
      host: true,
      allowedHosts: [
        'localhost',
        'boltdiy.mydomain.no'    #<-change this to your url 
      ],
    },

Hi @johnberntsen, adding your domain as an allowed host in vite config should fix this.

server: {
  host: true,
  allowedHosts: [
    'localhost',
    'bolt.diy.mydomain.no'
  ]
}

It works, could probably add a .env setting like ‘REVERSE_PROXY_HOST’ and use that setting to adjust this on the fly too.

@johnberntsen thanks for the reply. The main branch is more a “pre-release / beta” state, so if it works with stable and not with main, we got a bug here 😃

@xKevIsDev if you got time, can you please take a look here 😃

Hi @johnberntsen, did you maybe take a look at my youtube video on that? (not docker, but maybe still helps) https://youtu.be/-jy4kxKBBSw

Does this help or still get the problem?

Hi, thanks for the reply and great video! I see you are checking out the stable branch, which im sure dont have this issue, I usually check out the latest and greatest, but reverted back to v0.0.6 - which works for me.