adutra commented on code in PR #147:
URL: https://github.com/apache/polaris-tools/pull/147#discussion_r2737542400
##########
console/src/api/client.ts:
##########
@@ -20,14 +20,12 @@
import axios, { type AxiosInstance, type InternalAxiosRequestConfig } from
"axios"
import { navigate } from "@/lib/navigation"
import { REALM_HEADER_NAME } from "@/lib/constants"
+import { config } from "@/lib/config"
-// Always use relative URLs to go through the proxy (dev server or production
server)
-// This avoids CORS issues by proxying requests through the server
-// The server.ts proxy handles /api routes in production, and Vite handles
them in development
-const API_BASE_URL = ""
+const API_BASE_URL = config.POLARIS_API_URL
const MANAGEMENT_BASE_URL = `${API_BASE_URL}/api/management/v1`
const CATALOG_BASE_URL = `${API_BASE_URL}/api/catalog/v1`
-const POLARIS_BASE_URL = `${API_BASE_URL}/polaris/v1`
+const POLARIS_BASE_URL = `${API_BASE_URL}/api/catalog/polaris/v1`
Review Comment:
This doesn't look right, it should read:
```suggestion
const POLARIS_BASE_URL = `${API_BASE_URL}/api/polaris/v1`
```
##########
console/README.md:
##########
@@ -45,12 +45,70 @@ Create a `.env` file based on `.env.example`:
```env
VITE_POLARIS_API_URL=http://localhost:8181
-VITE_POLARIS_REALM=POLARIS
+VITE_POLARIS_REALM=POLARIS
VITE_POLARIS_PRINCIPAL_SCOPE=PRINCIPAL_ROLE:ALL
VITE_POLARIS_REALM_HEADER_NAME=Polaris-Realm # optional, defaults to
"Polaris-Realm"
-VITE_OAUTH_TOKEN_URL=http://localhost:8181/api/v1/oauth/tokens # optional
+VITE_OAUTH_TOKEN_URL=http://localhost:8181/api/catalog/v1/oauth/tokens #
optional, defaults to ${VITE_POLARIS_API_URL}/api/catalog/v1/oauth/tokens
```
+> **Note:** The console makes direct API calls to the Polaris server. Ensure
CORS is properly configured on the server (see below).
+
+### Server-Side CORS Configuration
+
+The console makes direct API calls to the Polaris server. Configure CORS on
your Polaris server (Quarkus-based).
+
+#### Option 1: Using application.properties
+
+Add to your Polaris `application.properties` file:
+
+```properties
+quarkus.http.cors.enabled=true
+quarkus.http.cors.origins=http://localhost:5173,https://your-console-domain.com
Review Comment:
Maybe replace `http://localhost:5173` with a more meaningful URL?
##########
console/README.md:
##########
@@ -45,12 +45,70 @@ Create a `.env` file based on `.env.example`:
```env
VITE_POLARIS_API_URL=http://localhost:8181
-VITE_POLARIS_REALM=POLARIS
+VITE_POLARIS_REALM=POLARIS
VITE_POLARIS_PRINCIPAL_SCOPE=PRINCIPAL_ROLE:ALL
VITE_POLARIS_REALM_HEADER_NAME=Polaris-Realm # optional, defaults to
"Polaris-Realm"
-VITE_OAUTH_TOKEN_URL=http://localhost:8181/api/v1/oauth/tokens # optional
+VITE_OAUTH_TOKEN_URL=http://localhost:8181/api/catalog/v1/oauth/tokens #
optional, defaults to ${VITE_POLARIS_API_URL}/api/catalog/v1/oauth/tokens
```
+> **Note:** The console makes direct API calls to the Polaris server. Ensure
CORS is properly configured on the server (see below).
+
+### Server-Side CORS Configuration
+
+The console makes direct API calls to the Polaris server. Configure CORS on
your Polaris server (Quarkus-based).
+
+#### Option 1: Using application.properties
+
+Add to your Polaris `application.properties` file:
+
+```properties
+quarkus.http.cors.enabled=true
+quarkus.http.cors.origins=http://localhost:5173,https://your-console-domain.com
+quarkus.http.cors.methods=GET,POST,PUT,DELETE,PATCH,OPTIONS
+quarkus.http.cors.headers=Content-Type,Authorization,Polaris-Realm
+quarkus.http.cors.exposed-headers=*
+quarkus.http.cors.access-control-allow-credentials=true
+quarkus.http.cors.access-control-max-age=PT10M
+```
+
+#### Option 2: Using Environment Variables
+
+Set these environment variables:
+
+```bash
+QUARKUS_HTTP_CORS_ENABLED=true
+QUARKUS_HTTP_CORS_ORIGINS=http://localhost:5173,https://your-console-domain.com
+QUARKUS_HTTP_CORS_METHODS=GET,POST,PUT,DELETE,PATCH,OPTIONS
+QUARKUS_HTTP_CORS_HEADERS=Content-Type,Authorization,Polaris-Realm
+QUARKUS_HTTP_CORS_EXPOSED_HEADERS=*
+QUARKUS_HTTP_CORS_ACCESS_CONTROL_ALLOW_CREDENTIALS=true
+QUARKUS_HTTP_CORS_ACCESS_CONTROL_MAX_AGE=PT10M
+```
+
+#### Option 3: Using Kubernetes ConfigMap
+
+For Kubernetes/Helm deployments, create a ConfigMap:
Review Comment:
Polaris Helm chart has support for CORS:
https://github.com/apache/polaris/blob/1d7903c6fd0307601f448250ccf4770966114e10/helm/polaris/values.yaml#L726-L739
You don't need to create a configmap manually.
##########
console/README.md:
##########
@@ -45,12 +45,70 @@ Create a `.env` file based on `.env.example`:
```env
VITE_POLARIS_API_URL=http://localhost:8181
-VITE_POLARIS_REALM=POLARIS
+VITE_POLARIS_REALM=POLARIS
VITE_POLARIS_PRINCIPAL_SCOPE=PRINCIPAL_ROLE:ALL
VITE_POLARIS_REALM_HEADER_NAME=Polaris-Realm # optional, defaults to
"Polaris-Realm"
-VITE_OAUTH_TOKEN_URL=http://localhost:8181/api/v1/oauth/tokens # optional
+VITE_OAUTH_TOKEN_URL=http://localhost:8181/api/catalog/v1/oauth/tokens #
optional, defaults to ${VITE_POLARIS_API_URL}/api/catalog/v1/oauth/tokens
```
+> **Note:** The console makes direct API calls to the Polaris server. Ensure
CORS is properly configured on the server (see below).
+
+### Server-Side CORS Configuration
+
+The console makes direct API calls to the Polaris server. Configure CORS on
your Polaris server (Quarkus-based).
+
+#### Option 1: Using application.properties
+
+Add to your Polaris `application.properties` file:
+
+```properties
+quarkus.http.cors.enabled=true
+quarkus.http.cors.origins=http://localhost:5173,https://your-console-domain.com
+quarkus.http.cors.methods=GET,POST,PUT,DELETE,PATCH,OPTIONS
+quarkus.http.cors.headers=Content-Type,Authorization,Polaris-Realm
Review Comment:
Not sure if the UI makes use of request IDs, but maybe include
`X-Request-ID` just in case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]