P
Postiz•3mo ago
Support

Ticket: CORS Error on Localhost During Docker Deployment

@ceLL Just created a ticket
Question: Is CORS a problem when running on localhost? I have cloned the app, ran docker compose up, then on login page a CORS error is shown. I haven't found anything in the docs page related to this. Since is a localhost and not hosted anywhere, https is not required (also from the docs)
Attempted: I am a newbie in docker images so nothing much that I have tried.
Working On: I am trying to deploy the application locally.
Take it from here @Mod 🔥
49 Replies
Nevo David
Nevo David•3mo ago
Can you show us your .env file?
ceLL
ceLL•3mo ago
# Configuration reference: http://docs.postiz.com/configuration/reference

# === Required Settings
DATABASE_URL="postgresql://postiz-user:postiz-password@localhost:5432/postiz-db-local"
REDIS_URL="redis://localhost:6379"
JWT_SECRET="random string for your JWT secret, make it long"
FRONTEND_URL="http://localhost:4200"
NEXT_PUBLIC_BACKEND_URL="http://localhost:3000"
BACKEND_INTERNAL_URL="http://localhost:3000"

## These are dummy values, you must create your own from Cloudflare.
## Remember to set your public internet IP address in the allow-list for the API token.
##
## Cloudflare is currently required to save things like social media avatars for accounts.
CLOUDFLARE_ACCOUNT_ID="QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu"
CLOUDFLARE_ACCESS_KEY="dcfCMSuFEeCNfvByUureMZEfxWJmDqZe"
CLOUDFLARE_SECRET_ACCESS_KEY="zTTMXBmtyLPwHEdpACGHgDgzRTNpTJewiNriLnUS"
CLOUDFLARE_BUCKETNAME="postiz"
CLOUDFLARE_BUCKET_URL="https://QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu.r2.cloudflarestorage.com/"
CLOUDFLARE_REGION="auto"


# === Common optional Settings

## This is a dummy key, you must create your own from Resend.
## If this variable exists, user activation is required.
## If it is commented out, users are activated automatically.
#RESEND_API_KEY="RzeTwHijvxvPUerScFcenUZUALuQJzSaGSMJ"
#EMAIL_FROM_ADDRESS=""
#EMAIL_FROM_NAME=""

# Where will social media icons be saved - local or cloudflare.
STORAGE_PROVIDER="local"

# Your upload directory path if you host your files locally, otherwise Cloudflare will be used.
#UPLOAD_DIRECTORY=""

# Your upload directory path if you host your files locally, otherwise Cloudflare will be used.
#NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY=""

# Developer Settings
NX_ADD_PLUGINS=false
IS_GENERAL="true" # required for now
# Configuration reference: http://docs.postiz.com/configuration/reference

# === Required Settings
DATABASE_URL="postgresql://postiz-user:postiz-password@localhost:5432/postiz-db-local"
REDIS_URL="redis://localhost:6379"
JWT_SECRET="random string for your JWT secret, make it long"
FRONTEND_URL="http://localhost:4200"
NEXT_PUBLIC_BACKEND_URL="http://localhost:3000"
BACKEND_INTERNAL_URL="http://localhost:3000"

## These are dummy values, you must create your own from Cloudflare.
## Remember to set your public internet IP address in the allow-list for the API token.
##
## Cloudflare is currently required to save things like social media avatars for accounts.
CLOUDFLARE_ACCOUNT_ID="QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu"
CLOUDFLARE_ACCESS_KEY="dcfCMSuFEeCNfvByUureMZEfxWJmDqZe"
CLOUDFLARE_SECRET_ACCESS_KEY="zTTMXBmtyLPwHEdpACGHgDgzRTNpTJewiNriLnUS"
CLOUDFLARE_BUCKETNAME="postiz"
CLOUDFLARE_BUCKET_URL="https://QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu.r2.cloudflarestorage.com/"
CLOUDFLARE_REGION="auto"


# === Common optional Settings

## This is a dummy key, you must create your own from Resend.
## If this variable exists, user activation is required.
## If it is commented out, users are activated automatically.
#RESEND_API_KEY="RzeTwHijvxvPUerScFcenUZUALuQJzSaGSMJ"
#EMAIL_FROM_ADDRESS=""
#EMAIL_FROM_NAME=""

# Where will social media icons be saved - local or cloudflare.
STORAGE_PROVIDER="local"

# Your upload directory path if you host your files locally, otherwise Cloudflare will be used.
#UPLOAD_DIRECTORY=""

# Your upload directory path if you host your files locally, otherwise Cloudflare will be used.
#NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY=""

# Developer Settings
NX_ADD_PLUGINS=false
IS_GENERAL="true" # required for now
I deleted irrelevant infos, and i have changed nothing
Nevo David
Nevo David•3mo ago
Can you try to change NEXT_PUBLIC_BACKEND_URL and BACKEND_INTERNAL_URL to
http://localhost:4200/api
http://localhost:4200/api
ceLL
ceLL•3mo ago
NEXT_PUBLIC_BACKEND_URL="http://localhost:4200/api"
BACKEND_INTERNAL_URL="http://localhost:4200/api"
NEXT_PUBLIC_BACKEND_URL="http://localhost:4200/api"
BACKEND_INTERNAL_URL="http://localhost:4200/api"
Nevo David
Nevo David•3mo ago
Yes
ceLL
ceLL•3mo ago
PrismaClientInitializationError: Authentication failed against database server at `postiz-postgres`, the provided database credentials for `postiz-user` are not valid.
PrismaClientInitializationError: Authentication failed against database server at `postiz-postgres`, the provided database credentials for `postiz-user` are not valid.
From docker logs
postiz-postgres | 2024-10-11 08:13:56.453 UTC [66] FATAL: role "postiz-user" does not exist
postiz-postgres | 2024-10-11 08:14:06.497 UTC [74] FATAL: role "postiz-user" does not exist
postiz-postgres | 2024-10-11 08:13:56.453 UTC [66] FATAL: role "postiz-user" does not exist
postiz-postgres | 2024-10-11 08:14:06.497 UTC [74] FATAL: role "postiz-user" does not exist
Nevo David
Nevo David•3mo ago
looks like you haven't modified your
DATABASE_URL
DATABASE_URL
ceLL
ceLL•3mo ago
Should i modify it to what? from docker file?
environment:
POSTGRES_PASSWORD: postiz-password
POSTGRES_USER: postiz-user
POSTGRES_DB: postiz-db-local
environment:
POSTGRES_PASSWORD: postiz-password
POSTGRES_USER: postiz-user
POSTGRES_DB: postiz-db-local
Nevo David
Nevo David•3mo ago
Can you paste here your docker-compose file that you are using?
ceLL
ceLL•3mo ago
it's the one from the documentation.
Nevo David
Nevo David•3mo ago
Can you check that your postgres database is running?
ceLL
ceLL•3mo ago
I think so:
No description
Nevo David
Nevo David•3mo ago
Can you try this db url instead?
postgres://postiz-user:postiz-password@postiz-postgres:5432/postiz-db-local
postgres://postiz-user:postiz-password@postiz-postgres:5432/postiz-db-local
ceLL
ceLL•3mo ago
in .env or compose file?
Nevo David
Nevo David•3mo ago
do in both I am not sure how @xcons configured it
ceLL
ceLL•3mo ago
same
No description
Nevo David
Nevo David•3mo ago
When you click on postiz-postgres on the docker what are the logs you see?
ceLL
ceLL•3mo ago
2024-10-11 11:21:57 2024-10-11 08:21:57.098 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-10-11 11:21:57 2024-10-11 08:21:57.106 UTC [26] LOG: database system was shut down at 2024-10-11 08:21:04 UTC
2024-10-11 11:21:57 2024-10-11 08:21:57.111 UTC [1] LOG: database system is ready to accept connections
2024-10-11 11:22:07 2024-10-11 08:22:07.057 UTC [40] FATAL: role "postiz-user" does not exist
2024-10-11 11:22:09 2024-10-11 08:22:09.546 UTC [41] FATAL: password authentication failed for user "postiz-user"
2024-10-11 11:22:09 2024-10-11 08:22:09.546 UTC [41] DETAIL: Role "postiz-user" does not exist.
2024-10-11 11:22:09 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2024-10-11 11:22:14 2024-10-11 08:22:14.161 UTC [42] FATAL: password authentication failed for user "postiz-user"
2024-10-11 11:22:14 2024-10-11 08:22:14.161 UTC [42] DETAIL: Role "postiz-user" does not exist.
2024-10-11 11:22:14 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2024-10-11 11:22:14 2024-10-11 08:22:14.358 UTC [43] FATAL: password authentication failed for user "postiz-user"
2024-10-11 11:22:14 2024-10-11 08:22:14.358 UTC [43] DETAIL: Role "postiz-user" does not exist.
2024-10-11 11:22:14 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2024-10-11 11:22:15 2024-10-11 08:22:15.620 UTC [44] FATAL: password authentication failed for user "postiz-user"
2024-10-11 11:22:15 2024-10-11 08:22:15.620 UTC [44] DETAIL: Role "postiz-user" does not exist.
2024-10-11 11:22:15 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2024-10-11 11:23:17 2024-10-11 08:23:17.392 UTC [100] FATAL: role "postiz-user" does not exist
2024-10-11 11:23:27 2024-10-11 08:23:27.437 UTC [108] FATAL: role "postiz-user" does not exist
2024-10-11 11:23:37 2024-10-11 08:23:37.482 UTC [116] FATAL: role "postiz-user" does not exist
2024-10-11 11:21:57 2024-10-11 08:21:57.098 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-10-11 11:21:57 2024-10-11 08:21:57.106 UTC [26] LOG: database system was shut down at 2024-10-11 08:21:04 UTC
2024-10-11 11:21:57 2024-10-11 08:21:57.111 UTC [1] LOG: database system is ready to accept connections
2024-10-11 11:22:07 2024-10-11 08:22:07.057 UTC [40] FATAL: role "postiz-user" does not exist
2024-10-11 11:22:09 2024-10-11 08:22:09.546 UTC [41] FATAL: password authentication failed for user "postiz-user"
2024-10-11 11:22:09 2024-10-11 08:22:09.546 UTC [41] DETAIL: Role "postiz-user" does not exist.
2024-10-11 11:22:09 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2024-10-11 11:22:14 2024-10-11 08:22:14.161 UTC [42] FATAL: password authentication failed for user "postiz-user"
2024-10-11 11:22:14 2024-10-11 08:22:14.161 UTC [42] DETAIL: Role "postiz-user" does not exist.
2024-10-11 11:22:14 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2024-10-11 11:22:14 2024-10-11 08:22:14.358 UTC [43] FATAL: password authentication failed for user "postiz-user"
2024-10-11 11:22:14 2024-10-11 08:22:14.358 UTC [43] DETAIL: Role "postiz-user" does not exist.
2024-10-11 11:22:14 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2024-10-11 11:22:15 2024-10-11 08:22:15.620 UTC [44] FATAL: password authentication failed for user "postiz-user"
2024-10-11 11:22:15 2024-10-11 08:22:15.620 UTC [44] DETAIL: Role "postiz-user" does not exist.
2024-10-11 11:22:15 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2024-10-11 11:23:17 2024-10-11 08:23:17.392 UTC [100] FATAL: role "postiz-user" does not exist
2024-10-11 11:23:27 2024-10-11 08:23:27.437 UTC [108] FATAL: role "postiz-user" does not exist
2024-10-11 11:23:37 2024-10-11 08:23:37.482 UTC [116] FATAL: role "postiz-user" does not exist
Nevo David
Nevo David•3mo ago
it looks like it didn't create it so well can you try maybe to remove all the docker and run everything again?
ceLL
ceLL•3mo ago
i deleted everything, unzipped the project, created docker-compose yaml file & .env file from documentation, and run docker compose up
ceLL
ceLL•3mo ago
No description
Nevo David
Nevo David•3mo ago
I am not sure why but it's not creating the user in postgres @xcons can you have a look when you have some time?
ceLL
ceLL•3mo ago
Postiz Documentation
Docker Compose – Postiz Docs
Postiz - Open source social media scheduling tool
Nevo David
Nevo David•3mo ago
Did you create a new docker-compose.yml file or used the existing one docker-compose.dev.yaml
ceLL
ceLL•3mo ago
I created a new file. I did a full clean up, deleted everything from docker, and locally, did it from the beginning Now the issue is not appearing anymore
ceLL
ceLL•3mo ago
on login / sign-up page:
No description
ceLL
ceLL•3mo ago
Does it have default credentials to be used?
Nevo David
Nevo David•3mo ago
oh you are running it locally
ceLL
ceLL•3mo ago
Yes
Nevo David
Nevo David•3mo ago
This needs to be
NEXT_PUBLIC_BACKEND_URL="http://localhost:5000/api"
BACKEND_INTERNAL_URL="http://localhost:5000/api"
FRONTEND_URL="http://localhost:5000"
NEXT_PUBLIC_BACKEND_URL="http://localhost:5000/api"
BACKEND_INTERNAL_URL="http://localhost:5000/api"
FRONTEND_URL="http://localhost:5000"
in .env file
ceLL
ceLL•3mo ago
I did not find anything related to this
Nevo David
Nevo David•3mo ago
What do you mean?
ceLL
ceLL•3mo ago
wanted to point to this, sorry
Nevo David
Nevo David•3mo ago
Change it also in the docker composer file
ceLL
ceLL•3mo ago
you mean these ones?
MAIN_URL: "https://postiz.your-server.com"
FRONTEND_URL: "https://postiz.your-server.com"
NEXT_PUBLIC_BACKEND_URL: "https://postiz.your-server.com/api"
MAIN_URL: "https://postiz.your-server.com"
FRONTEND_URL: "https://postiz.your-server.com"
NEXT_PUBLIC_BACKEND_URL: "https://postiz.your-server.com/api"
Nevo David
Nevo David•3mo ago
Yes
ceLL
ceLL•3mo ago
Main url should point to http://localhost:5000/ ?
Nevo David
Nevo David•3mo ago
yes without the "/"
ceLL
ceLL•3mo ago
environment:
# You must change these. Replace `postiz.your-server.com` with your DNS name - what your web browser sees.
MAIN_URL: "http://localhost:5000"
FRONTEND_URL: "http://localhost:5000"
NEXT_PUBLIC_BACKEND_URL: "http://localhost:5000/api"
JWT_SECRET: "gsdfgetgwegfasfasfasdasdwqdwqdsa"
# These defaults are probably fine, but if you change your user/password, update it in the
# postiz-postgres or postiz-redis services below.
DATABASE_URL: "postgresql://postiz-user:postiz-password@postiz-postgres:5432/postiz-db-local"
REDIS_URL: "redis://postiz-redis:6379"
BACKEND_INTERNAL_URL: "http://localhost:5000/api"
IS_GENERAL: "true" # Required for self-hosting.
# The container images are pre-configured to use /uploads for file storage.
# You probably should not change this unless you have a really good reason!
STORAGE_PROVIDER: "local"
UPLOAD_DIRECTORY: "/uploads"
NEXT_PUBLIC_UPLOAD_DIRECTORY: "/uploads"
environment:
# You must change these. Replace `postiz.your-server.com` with your DNS name - what your web browser sees.
MAIN_URL: "http://localhost:5000"
FRONTEND_URL: "http://localhost:5000"
NEXT_PUBLIC_BACKEND_URL: "http://localhost:5000/api"
JWT_SECRET: "gsdfgetgwegfasfasfasdasdwqdwqdsa"
# These defaults are probably fine, but if you change your user/password, update it in the
# postiz-postgres or postiz-redis services below.
DATABASE_URL: "postgresql://postiz-user:postiz-password@postiz-postgres:5432/postiz-db-local"
REDIS_URL: "redis://postiz-redis:6379"
BACKEND_INTERNAL_URL: "http://localhost:5000/api"
IS_GENERAL: "true" # Required for self-hosting.
# The container images are pre-configured to use /uploads for file storage.
# You probably should not change this unless you have a really good reason!
STORAGE_PROVIDER: "local"
UPLOAD_DIRECTORY: "/uploads"
NEXT_PUBLIC_UPLOAD_DIRECTORY: "/uploads"
Nevo David
Nevo David•3mo ago
yeah
ceLL
ceLL•3mo ago
managed to reach this page:
No description
ceLL
ceLL•3mo ago
So probably now it works
Nevo David
Nevo David•3mo ago
yup 🙂
ceLL
ceLL•3mo ago
in .env i belive i need to set my api keys for everything
Nevo David
Nevo David•3mo ago
yes
ceLL
ceLL•3mo ago
does it needs to have any other config files ? or just the id and secret and it's fine
Nevo David
Nevo David•3mo ago
Just follow all of them from the docs 🙂 You will find a section Providers Configurations
ceLL
ceLL•3mo ago
This can be closed for now. Thank you
Support
SupportOP•3mo ago
This thread is now closed! Feel free to open a new one if you need help

Did you find this page helpful?