Angular application showing "Blocked request"
farazbangalore
PROOP

7 months ago

Hi, I deployed angular application.
When i try to access it via public URL, it says

Blocked request. This host ("nextroleai-production.up.railway.app") is not allowed. To allow this host, add "nextroleai-production.up.railway.app" to server.allowedHosts in vite.config.js.

I dont have vite.config.js files, but i still added it. Still showing the error.

Kindly help!
Thanks in advance!

$10 Bounty

8 Replies

Railway
BOT

7 months ago


7 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 7 months ago


fra
HOBBYTop 10% Contributor

7 months ago

can you try with this?

import { defineConfig } from "vite";

export default defineConfig({
  server: {
    allowedHosts: true,
  },
});

this allows any domain, at least we can check if this is an app issue or railway issue (I don't think is a railway issue), if it works then you can start restricting the host, just remember that allowedHosts is an array, so you should use ["nextroleai-production.up.railway.app"] .

If you use docker remember to add this file to the image


fra

can you try with this?import { defineConfig } from "vite"; export default defineConfig({ server: { allowedHosts: true, }, });this allows any domain, at least we can check if this is an app issue or railway issue (I don't think is a railway issue), if it works then you can start restricting the host, just remember that allowedHosts is an array, so you should use ["nextroleai-production.up.railway.app"] .If you use docker remember to add this file to the image

farazbangalore
PROOP

7 months ago

Thanks for looking, but its not working.
This is my file path: src/vite.config.js
And this is the code
```
import { defineConfig } from "vite";

export default defineConfig({

server: {

allowedHosts: true,

},

});
```


fra
HOBBYTop 10% Contributor

7 months ago

Can you move the file in the root of the project?


fra

Can you move the file in the root of the project?

farazbangalore
PROOP

7 months ago

Moved, Now the path is: vite.config.js
Still didnt work!
If this can help,
Its an angular application and below are the files/folder in root

.vscode

Auth Working

public

src

.editorconfig

.gitignore

.postcssrc.json

Dockerfile

README.md

angular.json

package-lock.json

package.json

tsconfig.app.json

tsconfig.json

tsconfig.spec.json

vite.config.js

Attachments


fra
HOBBYTop 10% Contributor

7 months ago

Can you show the dockerfile?


fra

Can you show the dockerfile?

farazbangalore
PROOP

7 months ago

This is the docker content

# Use the Node alpine official image

# https://hub.docker.com/_/node

FROM node:lts-alpine

# Create and change to the app directory.

WORKDIR /app

# Copy the files to the container image

COPY package*.json ./

# Install packages

RUN npm ci

# Copy local code to the container image.

COPY . ./

# Build the app.

RUN npm run build

# Serve the app

CMD ["npm", "run", "start"]


fra
HOBBYTop 10% Contributor

7 months ago

I'm not expert with vite & angular, but can you try adding this in you angular.json

"serve": {
  "options": {
    "allowedHosts": ["your-domain"]
  },
}

Loading...