Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: api requests going to localhost:3000 when self hosting #6649

Closed
2 tasks done
arkodeep3404 opened this issue Oct 8, 2024 · 13 comments · Fixed by #6722
Closed
2 tasks done

🐛 Bug Report: api requests going to localhost:3000 when self hosting #6649

arkodeep3404 opened this issue Oct 8, 2024 · 13 comments · Fixed by #6722
Labels

Comments

@arkodeep3404
Copy link

📜 Description

hey there

i self hosted novu on a vm from azure but for some reason the api requests are going to localhost:3000 and not to my azure vm ip and hence they are failing

please help

👟 Reproduction steps

my .env file

Secrets

YOU MUST CHANGE THESE BEFORE GOING INTO PRODUCTION

used as a secret to verify the JWT token signature

JWT_SECRET=my-novu-jwt-secret-key

used to encrypt/decrypt the provider credentials

STORE_ENCRYPTION_KEY=3JkvVsN2PA+XyQTt+PEO8JiNFYBywkoK

Host

HOST_NAME=http://20.51.212.149

General

available values 'dev', 'test', 'production', 'ci', 'local'

NODE_ENV=production
MONGO_MAX_POOL_SIZE=200
MONGO_MIN_POOL_SIZE=75

MONGO USER

MONGO_INITDB_ROOT_USERNAME=root

MONGO PASSWORD

MONGO_INITDB_ROOT_PASSWORD=secret
MONGO_URL=mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongodb:27017/novu-db?authSource=admin
REDIS_HOST=redis

DOCKER_REDIS_SERVICE_PORT=6379
REDIS_PASSWORD=
REDIS_CACHE_SERVICE_HOST=

AWS

S3_LOCAL_STACK=$HOST_NAME:4566
S3_BUCKET_NAME=novu-local
S3_REGION=us-east-1
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test

Ports

API_PORT=3000
REDIS_PORT=6379
REDIS_CACHE_SERVICE_PORT=6379
WS_PORT=3002

Root URL

REACT_APP_WS_URL=$HOST_NAME:3002

Uncomment this one when deploying Novu in the local environment

as Web app local Dockerfile will have to load this to be used.

Deployment version doesn't need as we inject it with API_ROOT_URL value.

REACT_APP_API_URL=http://20.51.212.149:3000
API_ROOT_URL=$HOST_NAME:3000
DISABLE_USER_REGISTRATION=false
FRONT_BASE_URL=$HOST_NAME:4200
WIDGET_EMBED_PATH=$HOST_NAME:4701/embed.umd.min.js
WIDGET_URL=$HOST_NAME:4500

Context Paths

Only needed for setups with reverse-proxies

GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=web
API_CONTEXT_PATH=api
WS_CONTEXT_PATH=ws
WIDGET_CONTEXT_PATH=widget

Analytics

SENTRY_DSN=

change these values

NEW_RELIC_APP_NAME=
NEW_RELIC_LICENSE_KEY=

BROADCAST_QUEUE_CHUNK_SIZE=100
MULTICAST_QUEUE_CHUNK_SIZE=100

👍 Expected behavior

the actual requests should go to my azure VM IP and not to localhost

👎 Actual Behavior with Screenshots

the request should ideally go to my azure VM IP and not to my localhost

Screenshot 2024-10-08 at 3 20 56 PM

Novu version

docker:latest

npm version

docker

node version

docker

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

Copy link

linear bot commented Oct 8, 2024

@github-actions github-actions bot added the triage label Oct 8, 2024
@abhishek-singh0710
Copy link

Hi, I'm completely new to open-source so if you could guide me I would like to work on this issue.
How can I reproduce this?
Thanks.

@arkodeep3404
Copy link
Author

i just followed this guide on the official website and for some reason it doesn't seem to be working
https://docs.novu.co/community/self-hosting-novu/deploy-with-docker

@ArjixWasTaken
Copy link

ArjixWasTaken commented Oct 13, 2024

Please edit your issue description to use a code block for the .env file.
The comments are interpreted as markdown headers...

https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

@jainpawan21
Copy link
Member

@arkodeep3404

comment this line

REACT_APP_API_URL=http://20.51.212.149:3000

clean all the containers and restart using docker-compose up

@L-U-C-K-Y
Copy link
Contributor

@jainpawan21 I am facing the same issue:

image

I directly pass the URL to the container, why should I comment the line?

REACT_APP_API_URL=https://novu.domain.com

Many thanks!

@bledar
Copy link

bledar commented Oct 18, 2024

Seems that env variables are not loaded correctly on container is started. Updating the start command of the container will fix the problem.
npm run envsetup:docker && http-server build -p 4200 --proxy http://127.0.0.1:4200

@L-U-C-K-Y
Copy link
Contributor

Seems that env variables are not loaded correctly on container is started. Updating the start command of the container will fix the problem. npm run envsetup:docker && http-server build -p 4200 --proxy http://127.0.0.1:4200

Thanks for your reply @bledar, are you using Novu with docker?
I think I cannot add this to the docker images, or is there a way?

Thanks!

@ArjixWasTaken
Copy link

@L-U-C-K-Y you can always create a child image that overrides the entry point.

@L-U-C-K-Y
Copy link
Contributor

@ArjixWasTaken @bledar many thanks for your help, it's working!

If helpful for other people, I created a PR: #6722

@awbx
Copy link
Contributor

awbx commented Oct 22, 2024

try this

#!/bin/bash

docker compose up --force-recreate novu-web -d

docker compose exec -T novu-web bash <<'EOF'
        sed -i 's|src="/|src="/novu/web/|g; s|href="/|href="/novu/web/|g' build/index.html
        
        # hardcoded for now
        export GLOBAL_CONTEXT_PATH="/novu/web"
        echo -e "\nGLOBAL_CONTEXT_PATH=" >> .env

        ./env.sh
        mv ./env-config.js ./build/env-config.js
EOF

@katyaterletskaya
Copy link
Contributor

@jainpawan21 Would it be possible to consider publishing a new image to address this issue? 🙂

@jainpawan21
Copy link
Member

@katyaterletskaya

This issue should be resolved with this PR merge. Could you pull latest changes as there is one change in docker-compose.yml file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants