#Run Novu in Ubuntu cloud + ApiKey

1 messages Β· Page 1 of 1 (latest)

icy wind
#

How can i get ApiKey after running Novu locally?

stable fulcrum
#

sign up using the UI you also need to run locally

icy wind
#

Got it, i have some troubles setting up the .env variables

#

i have mongo and redis

#

and i already updated API_ROOT_URL and FRONT_BASE_URL

#

but the web app still calls localhost:3000

#

im updating the wrong .env

stable fulcrum
#

are you running it locally in docker or with pnpm in terminal?

icy wind
#

pnpm

stable fulcrum
#

have you restarted frontend and backend

icy wind
#

yes

#

and then i run npm run start and select api+ frontend

drifting sinewBOT
#

@icy wind, you just advanced to level 1!

icy wind
#

but let me try one more time

#

im updating novu/apps/api/src/.env it that right?

stable fulcrum
#

yes

#

you need to edit the env for the web as well

icy wind
#

ahhhh

#

let me do it

stable fulcrum
#

otherwise web will not know where you have your api service running and will go with default that is localhost:3000

icy wind
#
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=
REACT_APP_WIDGET_SDK_PATH=
REACT_APP_ENVIRONMENT=dev
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
#

i add there API_ROOT_URL?

stable fulcrum
#

you need to change REACT_APP_API_URL

icy wind
#

or REACT_APP_API_URL

#

okok

#

still trying to request localhost

stable fulcrum
#

and you have restarted both?

icy wind
#

yes

#

/home/novu/apps/web# sudo nano .env

#
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=http://watcher.feralbyte.com:4200
REACT_APP_WIDGET_SDK_PATH=
REACT_APP_ENVIRONMENT=dev
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
stable fulcrum
#

and what is FRONT_BASE_URL?

icy wind
#

on api/src/.env

NODE_ENV=local
PORT=3000
API_ROOT_URL=http://watcher.feralbyte.com:3000
FRONT_BASE_URL=http://watcher.feralbyte.com:4200
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false
stable fulcrum
#

and what is NODE_ENV?

#

is api running on 3000?

icy wind
#
Connected!
Waiting for localhost:4200.
Connected!

Everything is running 🎊

  Web: http://localhost:4200
  API: http://localhost:3000
```
drifting sinewBOT
#

@icy wind, you just advanced to level 2!

stable fulcrum
#

REACT_APP_API_URL=http://watcher.feralbyte.com:3000

#

in web .env

icy wind
#

...

#

sorry

stable fulcrum
#

np

#

did you get it to work?

icy wind
#

its restarting

stable fulcrum
#

πŸ‘

icy wind
#

I dont get it

stable fulcrum
#

why do you use http://watcher.feralbyte.com

#

lets try to use localhost instead and see if it works...

icy wind
#

The client side need to call the api right?

stable fulcrum
#

yes

icy wind
#

i dont need to point it?

stable fulcrum
#

REACT_APP_API_URL should do that

icy wind
#

ok and in the api urls i stick to localhost

#

let me try

#
NODE_ENV=local
PORT=3000
API_ROOT_URL=http://localhost:3000
FRONT_BASE_URL=http://localhost:4200
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false
#

in api .env

#

its restarting

#

nop, its calling localhost:3000

#

feels like im changing the wrong .env file

stable fulcrum
#

try remove build folder in web and restarting

icy wind
#

i need to go now, but in a couple of hours i will try

stable fulcrum
#

Ok might not be online at that point

icy wind
#

Thank you for your help πŸ™‚

stable fulcrum
#

no problem

icy wind
#

no problem you already helped a lot

#

thanks

icy wind
#

After removing build I can’t open the web app anymore

stable fulcrum
#

not even with the links provided in terminal?

icy wind
#

Im running on a cloud server

stable fulcrum
#

so lets change it back to it and remove build in web and see if it works

icy wind
#
NODE_ENV=local
PORT=3000
API_ROOT_URL=http://watcher.feralbyte.com:3000
FRONT_BASE_URL=http://watcher.feralbyte.com:4200
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false
#

But the web app continues to call localhost

stable fulcrum
#

yeah it is the .env in web you need to modify as well

icy wind
#

Hey David good morning!
These are my .env
/apps/web/.env

SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=http://watcher.feralbyte.com:3000
REACT_APP_WIDGET_SDK_PATH=
REACT_APP_ENVIRONMENT=dev
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=

/apps/api/src

NODE_ENV=local
PORT=3000
API_ROOT_URL=http://watcher.feralbyte.com:3000
FRONT_BASE_URL=http://watcher.feralbyte.com:4200
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false
drifting sinewBOT
#

@icy wind, you just advanced to level 3!

icy wind
#

and i run npm run start

Run the project
WEB & API

stable fulcrum
#

hm and it is not working?

icy wind
#

yes :/

stable fulcrum
#

@fleet viper or @cyan terrace could I get your help here πŸ™‚

icy wind
#

I can reinstall everything and try

stable fulcrum
#

I do not think that is the problem

icy wind
#

in jarvis when i select Development environment setup i get this:
./scripts/dev-environment-setup.sh: 66: Syntax error: redirection unexpected

#

im using ubuntu 22 and node 16

cyan terrace
#

Regarding your problem if right now you are trying running the apps individually in your local machine you need to remove the value REACT_APP_API_URL=http://watcher.feralbyte.com:3000 from /apps/web/.env and leave it like REACT_APP_API_URL=

#

And your /apps/web/.env to:

API_ROOT_URL=http://localhost:3000
FRONT_BASE_URL=http://localhost:4200
#

If you are still trying to run it in your cloud server, let me know so we can try to debug and find the problem helping you.

icy wind
#

I cant try this in my local machine im trying to run in on a cloud server

#

What changes do i need to on the web and api .env?

#

i have reverted the .envs

#

i have this:

root@vmi1174668:~# tail -100 /home/novu/apps/web/.env
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=
REACT_APP_WIDGET_SDK_PATH=
REACT_APP_ENVIRONMENT=dev
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
#

and this

root@vmi1174668:~# head /home/novu/apps/api/src/.env
NODE_ENV=local
PORT=3000
API_ROOT_URL=http://localhost:3000
FRONT_BASE_URL=http://localhost:4200
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false

MONGO_URL=mongodb://localhost:27017/novu-db
REDIS_PORT=6379
REDIS_PREFIX=
#

with that i got:

cyan terrace
#

this should work in your local machine and you should be able to run it

#

What's the response that /register call returns?

icy wind
#

But the Novu is on a cloud server, i cant run it there and access it from outside?

cyan terrace
#

Do you mean if you can use our cloud solution and have the Web app deployed in a different server requesting the calls against our cloud solution (api.novu.co)? Sorry, need to clarify this in order to be able to suggest solutions.

icy wind
#

Im trying to deploy Novu on my cloud ubuntu machine

#

everything needs to sit there: api + web app

cyan terrace
icy wind
#

yes

drifting sinewBOT
#

@icy wind, you just advanced to level 4!

icy wind
#

I need to change the .env from web app?

#

to point to http://watcher.feralbyte.com:3000/ right?

cyan terrace
#

You need to do the following changes.
In /apps/api/.env (please note the right location of the API)

NODE_ENV=prod
PORT=3000
API_ROOT_URL=http://watcher.feralbyte.com:3000
FRONT_BASE_URL=http://watcher.feralbyte.com:4200

Also you would need to set the proper URL where your MongoDB and Redis service are deployed:

MONGO_URL=mongodb://localhost:27017/novu-db // This won't work, unless you have deployed a MongoDB instance in your Cloud server
REDIS_HOST=<URL to the Redis host you will use>
REDIS_PORT=6379 

In /apps/web/.env:

REACT_APP_API_URL=http://watcher.feralbyte.com:3000
REACT_APP_ENVIRONMENT=prod

Also the scripts to run are the ones start:prod.

icy wind
#

I made the changes and run:
npm run start:web
npm run start:api

#

the web app still calls localhost

#

"Also the scripts to run are the ones start:prod. "
Can you explain me this please?

#

im running it incorrectly with npm run start:web?

#

i have mongo and redis installed in the machine

cyan terrace
# icy wind im running it incorrectly with `npm run start:web`?

No, sorry for confusing you. Basically the scripts in the root of the monorepo point to the scripts in both apps.
When doing:
pnpm run start:api
you are actually executing
pnpm run start in the folder /apps/api.
That script executes /apps/api/pnpm start:dev script that should be picking the .env file.

Could you please run Web app and API app with these scripts:

cd /apps/api
pnpm run start:prod

and

cd /apps/web
pnpm run start

So we can dismiss it is a problem with the scripts structure and the documentation?

icy wind
#

The problem continues :/

cyan terrace
#

Run Novu in Ubuntu cloud + ApiKey

#

Mind you share again your .env files for API and Web, please? Redact all the secrets, please.

icy wind
#
NODE_ENV=local
PORT=3000
API_ROOT_URL=http://watcher.feralbyte.com:3000
FRONT_BASE_URL=http://watcher.feralbyte.com:4200
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false

MONGO_URL=mongodb://localhost:27017/novu-db
REDIS_PORT=6379
REDIS_PREFIX=
REDIS_HOST=localhost
REDIS_DB_INDEX=2

REDIS_CACHE_SERVICE_HOST=
REDIS_CACHE_SERVICE_PORT=6379
REDIS_CACHE_DB_INDEX=
REDIS_CACHE_TTL=
REDIS_CACHE_PASSWORD=
REDIS_CACHE_CONNECTION_TIMEOUT=
REDIS_CACHE_KEEP_ALIVE=
REDIS_CACHE_FAMILY=
REDIS_CACHE_KEY_PREFIX=

JWT_SECRET=***********

S3_LOCAL_STACK=http://localhost:4566
S3_BUCKET_NAME=novu-local
S3_REGION=us-east-1
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
NEW_RELIC_ENABLED=false
CDN_URL=

MAIL_SERVER_DOMAIN=

GLOBAL_CONTEXT_PATH=
API_CONTEXT_PATH=
VERCEL_CLIENT_ID=
VERCEL_CLIENT_SECRET=
VERCEL_REDIRECT_URI=http://localhost:4200/auth/login
VERCEL_BASE_URL=https://api.vercel.com

FF_IS_TOPIC_NOTIFICATION_ENABLED=true

STORE_NOTIFICATION_CONTENT=true
#
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=http://watcher.feralbyte.com:3000
REACT_APP_WIDGET_SDK_PATH=
REACT_APP_ENVIRONMENT=prod
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
cyan terrace
#

Besides that, can you show the error message and status code received when you that call /auth/reset/request is executed?

icy wind
cyan terrace
#

I am sorry but that is not helpful enough. It totally looks like that you are deploying in the wrong URL the API because it doesn't even get the preflight requests.
Besides suggesting to change, as I did earlier, that the NODE_ENV must be set to prod (you missed to change it in the API app) I can't think of more things. Also remind you MongoDB url and Redis url are pointing to a local environment, so highly unlikely it will work all the set up.

#

Just a last question. That /request call is being executed just right the Web app is loaded? Or do you try any action?
Ok, I am assuming you are trying to execute the Forgot the password action, right?

icy wind
#

only to test the request

#

"d (you missed to change it in the API app) " yes i will change that

cyan terrace
#

Also, can you double check the location of the .env file for the API app?

#

I am trying to simulate in my local what it might be happening to you but I can't replicate it.

icy wind
#
root@vmi1174668:/home/novu/apps/api# dig +short myip.opendns.com @resolver1.opendns.com
84.46.246.26
root@vmi1174668:/home/novu/apps/api# head src/.env
NODE_ENV=prod
PORT=3000
API_ROOT_URL=http://84.46.246.26:3000
FRONT_BASE_URL=http://84.46.246.26:4200
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false

MONGO_URL=mongodb://localhost:27017/novu-db
REDIS_PORT=6379
REDIS_PREFIX=
#
root@vmi1174668:/home/novu/apps/web# head .env
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=http://84.46.246.26:3000
REACT_APP_WIDGET_SDK_PATH=
REACT_APP_ENVIRONMENT=prod
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
cyan terrace
icy wind
#

ok

cyan terrace
#

Another check you should do is:
In /apps/web/src/config/index.ts , to put a console.log to see if the Web app is picking the environment variables properly.
Such:

console.log(process.env.REACT_APP_API_URL);
console.log(window._env_.REACT_APP_API_URL);

put it in line 9 for example. Both should have as value http://84.46.246.26:3000, based on your Web app environment variables file.
Then in the console of the Browser you should be able to see the values logged.

icy wind
#

moved .env from api/src to api

#

i added the console logs

#

im restarting the web app

#

<--- Last few GCs --->

[43581:0x5537120]    63820 ms: Mark-sweep (reduce) 2043.3 (2082.7) -> 2042.7 (2083.2) MB, 1174.2 / 0.1 ms  (average mu = 0.154, current mu = 0.044) allocation failure scavenge might not succeed
[43581:0x5537120]    65232 ms: Mark-sweep (reduce) 2043.8 (2083.2) -> 2043.1 (2083.7) MB, 1402.0 / 0.1 ms  (average mu = 0.084, current mu = 0.008) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb08e80 node::Abort() [node]
 2: 0xa1b70e  [node]
 3: 0xce1890 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xce1c37 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xe992a5  [node]
 6: 0xea8f6d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 7: 0xeabc6e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0xe6d1aa v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
 9: 0x11e5f96 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
10: 0x15d9c19  [node]
#

cant start now

#

8gb ram and 4swap

#

rebooting

#

cloned the last repo
Installed using node 16
cant start web app

<--- Last few GCs --->

[2244:0x6518120]   151971 ms: Scavenge 2018.3 (2075.2) -> 2015.2 (2076.9) MB, 13.5 / 0.0 ms  (average mu = 0.829, current mu = 0.531) allocation failure 
[2244:0x6518120]   152019 ms: Scavenge 2019.9 (2076.9) -> 2016.7 (2080.7) MB, 22.8 / 0.0 ms  (average mu = 0.829, current mu = 0.531) allocation failure 
[2244:0x6518120]   152085 ms: Scavenge 2023.6 (2080.7) -> 2019.6 (2097.9) MB, 21.7 / 0.0 ms  (average mu = 0.829, current mu = 0.531) allocation failure 


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb08e80 node::Abort() [node]
 2: 0xa1b70e  [node]
 3: 0xce1890 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xce1c37 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xe992a5  [node]
 6: 0xea8f6d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 7: 0xeabc6e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0xe6d1aa v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
 9: 0x11e5f96 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
10: 0x15d9c19  [node]
npm ERR! Lifecycle script `start` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @novu/[email protected] 
npm ERR!   at location: /home/novu/apps/web 
#

after running npm run setup:project im back at the same problem regarding the request failure

cyan terrace
icy wind
#

i manage to get it working with hardcoding the value:

export const API_ROOT =
  window._env_.REACT_APP_API_URL || (isBrowser() && (window as any).Cypress)
    ? window._env_.REACT_APP_API_URL || 'http://localhost:1336'
    : window._env_.REACT_APP_API_URL || 'http://watcher.feralbyte.com:3000';
#

and building the app

#

but i cant manage to use the apps/web/.env

icy wind
#

It's normal that I can copy the API key?

#

already tried to regenerate it

stable fulcrum
#

You can or you can't?

icy wind
#

i cant*

drifting sinewBOT
#

@icy wind, you just advanced to level 5!

icy wind
#

sorry

stable fulcrum
#

it's not a problem just needed to understand you clearly πŸ™‚

#

the copy buttons do not work on localhost because chrome and other browsers requires https for it to work

icy wind
#

got it i will try to build the apps and implement https

cyan terrace
# icy wind i manage to get it working with hardcoding the value: ```ts export const API_ROO...

One question, are you running the /apps/web script envsetup after modyfing the .env values for the Web app? That is needed to generate a file to load the proper env variables in window._env_ object and make the client pointing to the right API.
I think we have no clearly explained that in the docs but because the self hosted option is something we are not maintaining (and not providing deep support).

icy wind
cyan terrace
icy wind
#

even when i execute ./env.sh i still points to localhost

#
  1. changed web/.env
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=http://watcher.feralbyte.com:3000
REACT_APP_WIDGET_SDK_PATH=
REACT_APP_ENVIRONMENT=prod
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
#
  1. novu/apps/web# ./env.sh
#
  1. npm run build
icy wind
#

Got it, I needed to run npm run envsetup

#

Now its pointing correctly but i have problems registering

#

i was able to register previously without https

#

if i run the post with curl it runs ok

curl 'http://watcher.feralbyte.com:3000/v1/auth/register' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Referer;' \
  -H 'Content-Type: application/json' \
  --data-raw $'{"firstName":"hugo","lastName":"freire","email":"[email protected]","password":"************"}' \
  --compressed
#
{"statusCode":400,"message":"User already exists","error":"Bad Request"}
#

its related to strict-origin-when-cross-origin

stable fulcrum
icy wind
#

yes its true

#

but i only works when i used the curl post

#

inside de web app the request fails

#

with the same payload

#

i copy the same request

#

fails in the app
passes on curl

burnt sierra
#

Hey I can chime in on this. I have some fixes too.

#

Novu appears to work best with the context path is set to the default value. When you change it, there are issues on the api and also web side of things.

#

For instance the function call getContextPath will return the correct env variable with the URL / context path depending on who is calling the function.

#

How this function works is that is looks at the different env variables using the NodeJS call like process.env.GLOBAL_CONTEXT_PATH

#

However, this will not work in novu-web which is client side

#
case NovuComponentEnum.WEB:
  if (process.env.FRONT_BASE_CONTEXT_PATH) {
    contextPath += process.env.FRONT_BASE_CONTEXT_PATH + '/';
  }
#

As the client side does not have access to the env variables.

#

I fixed this locally with

#

sed -i "s|CONTEXT_PATH =.*|CONTEXT_PATH = '$CONTEXT_PATH';|g" $WEB_APP/src/config/index.ts

#

There are also a number of static images that do not work

#
# Prepend CONTEXT_PATH to references to the public/static folder
SED_COMMAND='s|\([\`"'\'']\)\/static|\1'${CONTEXT_PATH}'/static|g'
find "${WEB_APP}/src" -type f -name "*.tsx" -exec sed -i ${SED_COMMAND} {} +
#

I'll try to put together a PR with these updates

icy wind
#

Thank @burnt sierra i used yout command but replacing the wep path like this:

sed -i "s|CONTEXT_PATH =.*|CONTEXT_PATH = '$CONTEXT_PATH';|g" /home/novu/apps/web/src/config/index.ts
#

and rebuilt the web app but I keep receiving errors on the request :/

burnt sierra
#

My bad, I only shared a small part of my script, there are other changes too.

cyan terrace
burnt sierra
#

WEB_APP=/usr/src/app/apps/web
CONTEXT_PATH=/notifications/novu

# Update env files with the correct CONTEXT_PATH.
sed -i "s|GLOBAL_CONTEXT_PATH=.*|GLOBAL_CONTEXT_PATH=$CONTEXT_PATH|g" $WEB_APP/.env

# PUBLIC_URL is used during the react build process `pnpm build:web`
echo "PUBLIC_URL=$CONTEXT_PATH" >> $WEB_APP/.env

# Update TypeScript files with the correct CONTEXT_PATH.
sed -i "s|CONTEXT_PATH =.*|CONTEXT_PATH = '$CONTEXT_PATH';|g" $WEB_APP/src/config/index.ts

# Prepend CONTEXT_PATH to references to the public/static folder
SED_COMMAND='s|\([\`"'\'']\)\/static|\1'${CONTEXT_PATH}'/static|g'
find "${WEB_APP}/src" -type f -name "*.tsx" -exec sed -i ${SED_COMMAND} {} +

# The above command may result in increased line-length with some files, this may causes the build
# to fail due to linting errors. For this reason, disable linter errors when rebuilding.
echo '*' > $WEB_APP/.prettierignore

# Rebuild the project to incorporate the above changes.
pnpm build:web

(cd $WEB_APP || exit ; ./env.sh ; mv env-config.js ./build/)
#

Are you using a different context path for the web / api container or both?

icy wind
#

i don't fully grasp the context path

#

i installed everything on /home/novu

#

Does your script work if i replace /usr/src/app/apps/web to /home/novu/app/apps/web ?

cyan terrace
#

Context path is for the public URLs where API and Web are accessed.
Let's say you want to host your API and expose it in:
https://api.my-domain.com/api
And your Web in:
https://my-domain.com/app

The context path in those cases would be: /api for the API and /app for the Web app.

icy wind
#

humm its a path after the domain?

#

oohh make sense πŸ™‚

#

i dont have any

#

i can use this?

#!/bin/sh

WEB_APP=/home/novu/apps/web
CONTEXT_PATH=/

# Update env files with the correct CONTEXT_PATH.
sed -i "s|GLOBAL_CONTEXT_PATH=.*|GLOBAL_CONTEXT_PATH=$CONTEXT_PATH|g" $WEB_APP/.env

# PUBLIC_URL is used during the react build process `pnpm build:web`
echo "PUBLIC_URL=$CONTEXT_PATH" >> $WEB_APP/.env

# Update TypeScript files with the correct CONTEXT_PATH.
sed -i "s|CONTEXT_PATH =.*|CONTEXT_PATH = '$CONTEXT_PATH';|g" $WEB_APP/src/config/index.ts

# Prepend CONTEXT_PATH to references to the public/static folder
SED_COMMAND='s|\([\`"'\'']\)\/static|\1'${CONTEXT_PATH}'/static|g'
find "${WEB_APP}/src" -type f -name "*.tsx" -exec sed -i ${SED_COMMAND} {} +

# The above command may result in increased line-length with some files, this may causes the build
# to fail due to linting errors. For this reason, disable linter errors when rebuilding.
echo '*' > $WEB_APP/.prettierignore

# Rebuild the project to incorporate the above changes.
pnpm build:web

(cd $WEB_APP || exit ; ./env.sh ; mv env-config.js ./build/)
icy wind
#

didn't work :/

#

like you said the images are broken but its fine

#

but the request its failing :/

#

i will try a black context_path

#

seems more logical xD

burnt sierra
#

Can you detail out the different env variables you are setting up?

icy wind
#

sure

burnt sierra
#

If you don't have a context path, and you are just using / like in your screenshot, ignore everything I have said so far.

icy wind
#

ok ok

#
##  /home/novu/apps/api/src/.env
NODE_ENV=prod
PORT=3000
API_ROOT_URL=http://watcher.feralbyte.com:3000
FRONT_BASE_URL=https://watcher.feralbyte.com
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false
drifting sinewBOT
#

@icy wind, you just advanced to level 6!

icy wind
#
# /home/novu/apps/web/.env 
REACT_APP_API_URL=http://watcher.feralbyte.com:3000
REACT_APP_WIDGET_SDK_PATH=
REACT_APP_ENVIRONMENT=prod
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
PUBLIC_URL=/
PUBLIC_URL=/
PUBLIC_URL=/
PUBLIC_URL=/
PUBLIC_URL=/
PUBLIC_URL=/
PUBLIC_URL=/
PUBLIC_URL=/
PUBLIC_URL=
#

i need to do some clean up xD

burnt sierra
#

and on the api side of things?

icy wind
#

do you want the entire file?

burnt sierra
#

What is the URL that you use to first navigate to your website?

icy wind
#

http://watcher.feralbyte.com

burnt sierra
#

I agree that you need to complete some clean up as there are a number of things that appear to be going wrong from what I can see.

#

when fetching an image, the application appears to be doing scheme: https host: static filename: /images/logo-formerly-dark-bg.png

icy wind
icy wind
#

i will reinstall everything in post only the modifications and result

icy wind
#
git clone https://github.com/novuhq/novu.git
cd /home/novu
npm run setup:project

sudo nano /home/novu/apps/web/.env
head /home/novu/apps/web/.env

SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=http://watch.feralbyte.com:3000
REACT_APP_ENVIRONMENT=prod
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=

sudo nano /home/novu/apps/api/src/.env
head /home/novu/apps/api/src/.env

NODE_ENV=prod
PORT=3000
API_ROOT_URL=http://localhost:3000
FRONT_BASE_URL=https://watcher.feralbyte.com
STORE_ENCRYPTION_KEY="<ENCRYPTION_KEY_MUST_BE_32_LONG>"
DISABLE_USER_REGISTRATION=false

cd /home/novu/apps/web
npm run envsetup
npm run build
#

On the cloud server:

curl http://localhost:3000/v1/healthcheck
{"statusCode":404,"message":"Cannot GET /v1/healthcheck","error":"Not Found"}
burnt sierra
#

That looks a lot better, but I am guessing that your problem is with your nginx mappings.

#

Your API server was running on port 3000 earlier, nothing is running there now.

icy wind
#

I use nginx only to serve the web app

#

The port is open.
I need to do something on apps/api/src/.env?

icy wind
#

Hey guys, for local installation do you have more info to set this up?

#

Or I need to go for a docker solution

burnt sierra
#

There is some config issues with your nginx setup. When you first navigate to the root URL, you are redirected to the login. Refreshing that page will result in an error. Could you post your nginx config

icy wind
#

yes sure πŸ™‚ thanks for helping

#
server {
        server_name watcher.feralbyte.com;
        location / {
                 root /home/novu/apps/web/build;
                 index index.html;
        }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/watcher.feralbyte.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/watcher.feralbyte.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = watcher.feralbyte.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

        listen 80;
        server_name watcher.feralbyte.com;
    return 404; # managed by Certbot
}
#

i didn't do anything related to api service

icy wind
#

i need to redirect port 3000 to pass trough nginx with https?

icy wind
#
## NGINX CONFIG
        server_name watcher.feralbyte.com;
        location / {
                 root /home/novu/apps/web/build;
                 index index.html;
        }

        location /api {
                rewrite ^/api/?(.*)$ /$1 break;
                proxy_pass  http://127.0.0.1:3000;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
#

it's all good now πŸ™‚ thank you a lot @stable fulcrum @cyan terrace @burnt sierra cheers

icy wind
#

const novu = new Novu(process.env.NOVU_API_KEY)
how can i set my host server?

stable fulcrum
#

I think the second param is a config or host param

icy wind
#

const novu = new Novu("b0ed975b7c42438de88c72f1a169c4b1",{backendUrl: 'https://watcher.feralbyte.com/api'});

#

correct πŸ™‚ um super happy

stable fulcrum
#

Nice

icy wind
#

discord message working πŸ™‚

stable fulcrum
#

Great have a great day or evening