Skip to content

Localias host not allowed since latest vite update (works with localhost) #52

@IsabelleLePivain

Description

@IsabelleLePivain

I am running a NUXT 3 project in my local environment on localhost:8099.
We use localias to proxy it to frontend.domain.local.
We use yarn (yarn dev --host).

Since the last dependencies update, I am facing a known error that came up with a Vite update on frontend.domain.local, with a 403 status:

Blocked request. This host ("frontend.domain.local") is not allowed.
To allow this host, add "frontend.domain.local" to `server.allowedHosts` in vite.config.js.

This error only happens on frontend.domain.local, it doesn't occur on localhost:8099.

I found suggestions for fixes here on SO.

Using NUXT, we do not have a vite.config.js file so I tried the following:

  1. add a server: allowedHosts option to our nuxt.config.ts file
export default defineNuxtConfig({
  server: {
     allowedHosts: ['frontend.domain.local'],
  },
  1. add a new vite.config.ts file:
import { defineConfig } from "vite";
export default defineConfig({
  server: {
     host: 'frontend.domain.local',
     allowedHosts: ['frontend.domain.local'],
});

I also tried with the host key on both files.

  server: {
     host: 'frontend.domain.local',
  },

But I still get the 403 error "Blocked request. This host ("frontend.domain.local") is not allowed" on frontend.domain.local.

Unsure whether this issue relates to localias, or is exclusively a Vite/NUXT issue.

Could also relate to issue #48 Doesn't work with the vite dev server. But it seems that for the poster DeluxeOwl the fix in vite.config is working - while for us it isn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions