CORS headers missing #2189
-
Environment
Description of issueThe doc states:
It seems however, that no
docker-compose.yml
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
The CORS headers are set on a preflight request, not on the regular request. What you are showing is the output of the regular request. You can see the CORS headers in the following request:
|
Beta Was this translation helpful? Give feedback.
-
Hello, After your previous answer, I did not had the time to investigate why I keep getting the error of the Anyway, here is my setup: I prefer not to bind all services on the host ports, like the docker-compose file in the doc does. I prefer to setup an nginx www reverse proxy used as ingress. I remember trying adding the headers in the nginx config, but unsuccessfully, but I have to retry when I have more time. docker-compose.yml version: '3'
services:
db:
image: postgres
expose:
- "5432"
environment:
POSTGRES_DB: app_db
POSTGRES_USER: app_user
POSTGRES_PASSWORD: password
volumes:
- "./pgdata:/var/lib/postgresql/data"
pgadmin:
image: dpage/pgadmin4
expose:
- "8000"
environment:
PGADMIN_DEFAULT_EMAIL: user@domain.com
PGADMIN_DEFAULT_PASSWORD: password
PGADMIN_DISABLE_POSTFIX: true
PGADMIN_LISTEN_PORT: 8000
depends_on:
- db
postgrest:
image: postgrest/postgrest
expose:
- "3000"
environment:
PGRST_DB_URI: postgres://app_user:password@db:5432/app_db
PGRST_DB_SCHEMA: public
PGRST_DB_ANON_ROLE: app_user
PGRST_OPENAPI_SERVER_PROXY_URI: http://localhost/api/
PGRST_JWT_SECRET: SecretSecretSecretSecretSecretSecret
depends_on:
- db
swagger:
image: swaggerapi/swagger-ui
expose:
- "8080"
environment:
API_URL: /api/
depends_on:
- postgrest
www:
image: nginx
ports:
- "80:80"
volumes:
- "./html:/usr/share/nginx/html:ro"
- "./nginx.default.conf:/etc/nginx/conf.d/default.conf:ro"
depends_on:
- postgrest
- pgadmin
- swagger nginx.default.conf upstream postgrest {
server postgrest:3000;
}
upstream swagger {
server swagger:8080;
}
upstream pgadmin {
server pgadmin:8000;
}
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /api/ {
proxy_pass http://postgrest/;
}
location /swagger/ {
proxy_pass http://swagger/;
}
location /pgadmin/ {
proxy_set_header X-Script-Name /pgadmin;
proxy_pass http://pgadmin/;
}
}
|
Beta Was this translation helpful? Give feedback.
-
I could not do any request via swagger, because it fails fetching the openapi document.
The error is shown directly when you open swagger in the browser
|
Beta Was this translation helpful? Give feedback.
The CORS headers are set on a preflight request, not on the regular request. What you are showing is the output of the regular request.
You can see the CORS headers in the following request: