fix cors
This commit is contained in:
parent
6265ac534a
commit
87e330161b
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 4,
|
"version": 4,
|
||||||
"terraform_version": "1.10.1",
|
"terraform_version": "1.10.1",
|
||||||
"serial": 367,
|
"serial": 369,
|
||||||
"lineage": "a183cd95-f987-8698-c6dd-84e933c394a5",
|
"lineage": "a183cd95-f987-8698-c6dd-84e933c394a5",
|
||||||
"outputs": {
|
"outputs": {
|
||||||
"cloud_run_qdrant_host": {
|
"cloud_run_qdrant_host": {
|
||||||
@ -146,7 +146,7 @@
|
|||||||
"goog-terraform-provisioned": "true"
|
"goog-terraform-provisioned": "true"
|
||||||
},
|
},
|
||||||
"generation": 1,
|
"generation": 1,
|
||||||
"labels": null,
|
"labels": {},
|
||||||
"namespace": "gen-lang-client-0424120530",
|
"namespace": "gen-lang-client-0424120530",
|
||||||
"resource_version": "AAY16EtYS9U",
|
"resource_version": "AAY16EtYS9U",
|
||||||
"self_link": "/apis/serving.knative.dev/v1/namespaces/761163285547/services/sereact",
|
"self_link": "/apis/serving.knative.dev/v1/namespaces/761163285547/services/sereact",
|
||||||
@ -218,8 +218,8 @@
|
|||||||
"container_concurrency": 80,
|
"container_concurrency": 80,
|
||||||
"containers": [
|
"containers": [
|
||||||
{
|
{
|
||||||
"args": null,
|
"args": [],
|
||||||
"command": null,
|
"command": [],
|
||||||
"env": [
|
"env": [
|
||||||
{
|
{
|
||||||
"name": "FIRESTORE_DATABASE_NAME",
|
"name": "FIRESTORE_DATABASE_NAME",
|
||||||
@ -294,7 +294,7 @@
|
|||||||
"cpu": "1",
|
"cpu": "1",
|
||||||
"memory": "1Gi"
|
"memory": "1Gi"
|
||||||
},
|
},
|
||||||
"requests": null
|
"requests": {}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"startup_probe": [
|
"startup_probe": [
|
||||||
@ -316,7 +316,7 @@
|
|||||||
"working_dir": ""
|
"working_dir": ""
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"node_selector": null,
|
"node_selector": {},
|
||||||
"service_account_name": "761163285547-compute@developer.gserviceaccount.com",
|
"service_account_name": "761163285547-compute@developer.gserviceaccount.com",
|
||||||
"serving_state": "",
|
"serving_state": "",
|
||||||
"timeout_seconds": 300,
|
"timeout_seconds": 300,
|
||||||
@ -623,6 +623,12 @@
|
|||||||
"zone": "us-central1-a"
|
"zone": "us-central1-a"
|
||||||
},
|
},
|
||||||
"sensitive_attributes": [
|
"sensitive_attributes": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "get_attr",
|
||||||
|
"value": "metadata_startup_script"
|
||||||
|
}
|
||||||
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"type": "get_attr",
|
"type": "get_attr",
|
||||||
@ -656,12 +662,6 @@
|
|||||||
"type": "get_attr",
|
"type": "get_attr",
|
||||||
"value": "disk_encryption_key_rsa"
|
"value": "disk_encryption_key_rsa"
|
||||||
}
|
}
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"type": "get_attr",
|
|
||||||
"value": "metadata_startup_script"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiNiJ9",
|
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiNiJ9",
|
||||||
@ -690,7 +690,7 @@
|
|||||||
"delete_protection_state": "DELETE_PROTECTION_DISABLED",
|
"delete_protection_state": "DELETE_PROTECTION_DISABLED",
|
||||||
"deletion_policy": "ABANDON",
|
"deletion_policy": "ABANDON",
|
||||||
"earliest_version_time": "2025-05-24T21:09:24.677010Z",
|
"earliest_version_time": "2025-05-24T21:09:24.677010Z",
|
||||||
"etag": "IMTG8tCEvY0DMJL7/oiCvY0D",
|
"etag": "IJCLh6eGvY0DMKrW4vCEvY0D",
|
||||||
"id": "projects/gen-lang-client-0424120530/databases/sereact-imagedb",
|
"id": "projects/gen-lang-client-0424120530/databases/sereact-imagedb",
|
||||||
"key_prefix": "",
|
"key_prefix": "",
|
||||||
"location_id": "us-central1",
|
"location_id": "us-central1",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 4,
|
"version": 4,
|
||||||
"terraform_version": "1.10.1",
|
"terraform_version": "1.10.1",
|
||||||
"serial": 363,
|
"serial": 368,
|
||||||
"lineage": "a183cd95-f987-8698-c6dd-84e933c394a5",
|
"lineage": "a183cd95-f987-8698-c6dd-84e933c394a5",
|
||||||
"outputs": {
|
"outputs": {
|
||||||
"cloud_run_qdrant_host": {
|
"cloud_run_qdrant_host": {
|
||||||
@ -12,10 +12,35 @@
|
|||||||
"value": "10.128.0.6",
|
"value": "10.128.0.6",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"cloud_run_url": {
|
||||||
|
"value": "https://sereact-p64zpdtkta-uc.a.run.app",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"container_registry_url": {
|
"container_registry_url": {
|
||||||
"value": "gcr.io/gen-lang-client-0424120530/sereact",
|
"value": "gcr.io/gen-lang-client-0424120530/sereact",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"deployment_summary": {
|
||||||
|
"value": {
|
||||||
|
"cloud_run_url": "https://sereact-p64zpdtkta-uc.a.run.app",
|
||||||
|
"firestore_database": "sereact-imagedb",
|
||||||
|
"qdrant_endpoint": "http://34.71.6.1:6333",
|
||||||
|
"qdrant_host_ip": "34.71.6.1",
|
||||||
|
"static_ip_enabled": false,
|
||||||
|
"storage_bucket": "sereact-images"
|
||||||
|
},
|
||||||
|
"type": [
|
||||||
|
"object",
|
||||||
|
{
|
||||||
|
"cloud_run_url": "string",
|
||||||
|
"firestore_database": "string",
|
||||||
|
"qdrant_endpoint": "string",
|
||||||
|
"qdrant_host_ip": "string",
|
||||||
|
"static_ip_enabled": "bool",
|
||||||
|
"storage_bucket": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"firestore_database_id": {
|
"firestore_database_id": {
|
||||||
"value": "projects/gen-lang-client-0424120530/databases/sereact-imagedb",
|
"value": "projects/gen-lang-client-0424120530/databases/sereact-imagedb",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -98,7 +123,6 @@
|
|||||||
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
|
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
|
||||||
"instances": [
|
"instances": [
|
||||||
{
|
{
|
||||||
"status": "tainted",
|
|
||||||
"schema_version": 2,
|
"schema_version": 2,
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"autogenerate_revision_name": false,
|
"autogenerate_revision_name": false,
|
||||||
@ -110,25 +134,67 @@
|
|||||||
"run.googleapis.com/ingress": "all"
|
"run.googleapis.com/ingress": "all"
|
||||||
},
|
},
|
||||||
"effective_annotations": {
|
"effective_annotations": {
|
||||||
"run.googleapis.com/ingress": "all"
|
"run.googleapis.com/ingress": "all",
|
||||||
|
"run.googleapis.com/ingress-status": "all",
|
||||||
|
"run.googleapis.com/operation-id": "3653c984-38f6-42b8-b3c1-9a6814773095",
|
||||||
|
"run.googleapis.com/urls": "[\"https://sereact-761163285547.us-central1.run.app\",\"https://sereact-p64zpdtkta-uc.a.run.app\"]",
|
||||||
|
"serving.knative.dev/creator": "johnpccd3@gmail.com",
|
||||||
|
"serving.knative.dev/lastModifier": "johnpccd3@gmail.com"
|
||||||
},
|
},
|
||||||
"effective_labels": {
|
"effective_labels": {
|
||||||
|
"cloud.googleapis.com/location": "us-central1",
|
||||||
"goog-terraform-provisioned": "true"
|
"goog-terraform-provisioned": "true"
|
||||||
},
|
},
|
||||||
"generation": 0,
|
"generation": 1,
|
||||||
"labels": null,
|
"labels": {},
|
||||||
"namespace": "",
|
"namespace": "gen-lang-client-0424120530",
|
||||||
"resource_version": "",
|
"resource_version": "AAY16EtYS9U",
|
||||||
"self_link": "",
|
"self_link": "/apis/serving.knative.dev/v1/namespaces/761163285547/services/sereact",
|
||||||
"terraform_labels": {
|
"terraform_labels": {
|
||||||
"goog-terraform-provisioned": "true"
|
"goog-terraform-provisioned": "true"
|
||||||
},
|
},
|
||||||
"uid": ""
|
"uid": "c67276c9-0c25-4a6c-8f39-4ea942599769"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "sereact",
|
"name": "sereact",
|
||||||
"project": "gen-lang-client-0424120530",
|
"project": "gen-lang-client-0424120530",
|
||||||
"status": null,
|
"status": [
|
||||||
|
{
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"message": "",
|
||||||
|
"reason": "",
|
||||||
|
"status": "True",
|
||||||
|
"type": "Ready"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"message": "",
|
||||||
|
"reason": "",
|
||||||
|
"status": "True",
|
||||||
|
"type": "ConfigurationsReady"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"message": "",
|
||||||
|
"reason": "",
|
||||||
|
"status": "True",
|
||||||
|
"type": "RoutesReady"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"latest_created_revision_name": "sereact-00001-hw9",
|
||||||
|
"latest_ready_revision_name": "sereact-00001-hw9",
|
||||||
|
"observed_generation": 1,
|
||||||
|
"traffic": [
|
||||||
|
{
|
||||||
|
"latest_revision": true,
|
||||||
|
"percent": 100,
|
||||||
|
"revision_name": "sereact-00001-hw9",
|
||||||
|
"tag": "",
|
||||||
|
"url": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"url": "https://sereact-p64zpdtkta-uc.a.run.app"
|
||||||
|
}
|
||||||
|
],
|
||||||
"template": [
|
"template": [
|
||||||
{
|
{
|
||||||
"metadata": [
|
"metadata": [
|
||||||
@ -137,7 +203,9 @@
|
|||||||
"autoscaling.knative.dev/maxScale": "10"
|
"autoscaling.knative.dev/maxScale": "10"
|
||||||
},
|
},
|
||||||
"generation": 0,
|
"generation": 0,
|
||||||
"labels": {},
|
"labels": {
|
||||||
|
"run.googleapis.com/startupProbeType": "Default"
|
||||||
|
},
|
||||||
"name": "",
|
"name": "",
|
||||||
"namespace": "",
|
"namespace": "",
|
||||||
"resource_version": "",
|
"resource_version": "",
|
||||||
@ -147,32 +215,12 @@
|
|||||||
],
|
],
|
||||||
"spec": [
|
"spec": [
|
||||||
{
|
{
|
||||||
"container_concurrency": 0,
|
"container_concurrency": 80,
|
||||||
"containers": [
|
"containers": [
|
||||||
{
|
{
|
||||||
"args": null,
|
"args": [],
|
||||||
"command": null,
|
"command": [],
|
||||||
"env": [
|
"env": [
|
||||||
{
|
|
||||||
"name": "CORS_EXPOSE_HEADERS",
|
|
||||||
"value": "Content-Length,Content-Range",
|
|
||||||
"value_from": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "CORS_HEADERS",
|
|
||||||
"value": "Content-Type,Authorization,X-Requested-With",
|
|
||||||
"value_from": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "CORS_MAX_AGE",
|
|
||||||
"value": "3600",
|
|
||||||
"value_from": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "CORS_METHODS",
|
|
||||||
"value": "GET,POST,PUT,DELETE,OPTIONS",
|
|
||||||
"value_from": []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "FIRESTORE_DATABASE_NAME",
|
"name": "FIRESTORE_DATABASE_NAME",
|
||||||
"value": "sereact-imagedb",
|
"value": "sereact-imagedb",
|
||||||
@ -236,7 +284,7 @@
|
|||||||
"ports": [
|
"ports": [
|
||||||
{
|
{
|
||||||
"container_port": 8000,
|
"container_port": 8000,
|
||||||
"name": "",
|
"name": "http1",
|
||||||
"protocol": ""
|
"protocol": ""
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -246,18 +294,32 @@
|
|||||||
"cpu": "1",
|
"cpu": "1",
|
||||||
"memory": "1Gi"
|
"memory": "1Gi"
|
||||||
},
|
},
|
||||||
"requests": null
|
"requests": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"startup_probe": [
|
||||||
|
{
|
||||||
|
"failure_threshold": 1,
|
||||||
|
"grpc": [],
|
||||||
|
"http_get": [],
|
||||||
|
"initial_delay_seconds": 0,
|
||||||
|
"period_seconds": 240,
|
||||||
|
"tcp_socket": [
|
||||||
|
{
|
||||||
|
"port": 8000
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timeout_seconds": 240
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"startup_probe": [],
|
|
||||||
"volume_mounts": [],
|
"volume_mounts": [],
|
||||||
"working_dir": ""
|
"working_dir": ""
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"node_selector": null,
|
"node_selector": {},
|
||||||
"service_account_name": "",
|
"service_account_name": "761163285547-compute@developer.gserviceaccount.com",
|
||||||
"serving_state": "",
|
"serving_state": "",
|
||||||
"timeout_seconds": 0,
|
"timeout_seconds": 300,
|
||||||
"volumes": []
|
"volumes": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -327,10 +389,33 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mode": "managed",
|
"mode": "managed",
|
||||||
"type": "google_compute_address",
|
"type": "google_cloud_run_service_iam_member",
|
||||||
"name": "vector_db_static_ip",
|
"name": "public_access",
|
||||||
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
|
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
|
||||||
"instances": []
|
"instances": [
|
||||||
|
{
|
||||||
|
"schema_version": 0,
|
||||||
|
"attributes": {
|
||||||
|
"condition": [],
|
||||||
|
"etag": "BwY16Etxb+g=",
|
||||||
|
"id": "v1/projects/gen-lang-client-0424120530/locations/us-central1/services/sereact/roles/run.invoker/allUsers",
|
||||||
|
"location": "us-central1",
|
||||||
|
"member": "allUsers",
|
||||||
|
"project": "gen-lang-client-0424120530",
|
||||||
|
"role": "roles/run.invoker",
|
||||||
|
"service": "v1/projects/gen-lang-client-0424120530/locations/us-central1/services/sereact"
|
||||||
|
},
|
||||||
|
"sensitive_attributes": [],
|
||||||
|
"private": "bnVsbA==",
|
||||||
|
"dependencies": [
|
||||||
|
"google_cloud_run_service.sereact",
|
||||||
|
"google_compute_address.vector_db_static_ip",
|
||||||
|
"google_compute_instance.vector_db_vm",
|
||||||
|
"google_project_service.services",
|
||||||
|
"google_service_account.vector_db_sa"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mode": "managed",
|
"mode": "managed",
|
||||||
@ -605,7 +690,7 @@
|
|||||||
"delete_protection_state": "DELETE_PROTECTION_DISABLED",
|
"delete_protection_state": "DELETE_PROTECTION_DISABLED",
|
||||||
"deletion_policy": "ABANDON",
|
"deletion_policy": "ABANDON",
|
||||||
"earliest_version_time": "2025-05-24T21:09:24.677010Z",
|
"earliest_version_time": "2025-05-24T21:09:24.677010Z",
|
||||||
"etag": "IOyxoJSEvY0DMJL7/oiCvY0D",
|
"etag": "IIa6rZSGvY0DMKrW4vCEvY0D",
|
||||||
"id": "projects/gen-lang-client-0424120530/databases/sereact-imagedb",
|
"id": "projects/gen-lang-client-0424120530/databases/sereact-imagedb",
|
||||||
"key_prefix": "",
|
"key_prefix": "",
|
||||||
"location_id": "us-central1",
|
"location_id": "us-central1",
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class Settings(BaseSettings):
|
|||||||
# CORS settings
|
# CORS settings
|
||||||
CORS_ORIGINS: List[str] = ["*"]
|
CORS_ORIGINS: List[str] = ["*"]
|
||||||
CORS_METHODS: List[str] = ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
|
CORS_METHODS: List[str] = ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
|
||||||
CORS_HEADERS: List[str] = ["Content-Type", "Authorization", "X-Requested-With"]
|
CORS_HEADERS: List[str] = ["Content-Type", "Authorization", "X-Requested-With", "X-API-Key", "Accept", "Origin"]
|
||||||
CORS_EXPOSE_HEADERS: List[str] = ["Content-Length", "Content-Range"]
|
CORS_EXPOSE_HEADERS: List[str] = ["Content-Length", "Content-Range"]
|
||||||
CORS_MAX_AGE: int = 3600
|
CORS_MAX_AGE: int = 3600
|
||||||
|
|
||||||
@ -33,12 +33,8 @@ class Settings(BaseSettings):
|
|||||||
# Handle comma-separated format
|
# Handle comma-separated format
|
||||||
return [i.strip().strip("'\"") for i in env_origins.split(",")]
|
return [i.strip().strip("'\"") for i in env_origins.split(",")]
|
||||||
|
|
||||||
# Fallback to default if no env var
|
# Use the default value if no env var is set
|
||||||
if isinstance(v, str) and not v.startswith("["):
|
return v or ["*"]
|
||||||
return [i.strip() for i in v.split(",")]
|
|
||||||
elif not v: # If empty list, use defaults
|
|
||||||
return ["http://localhost:3000", "http://localhost:8000", "http://127.0.0.1:8000", "http://127.0.0.1:3000", "https://localhost:3000", "https://localhost:8000"]
|
|
||||||
return v
|
|
||||||
|
|
||||||
@field_validator("CORS_METHODS", mode="before")
|
@field_validator("CORS_METHODS", mode="before")
|
||||||
def assemble_cors_methods(cls, v):
|
def assemble_cors_methods(cls, v):
|
||||||
@ -52,7 +48,7 @@ class Settings(BaseSettings):
|
|||||||
env_headers = os.getenv("CORS_HEADERS")
|
env_headers = os.getenv("CORS_HEADERS")
|
||||||
if env_headers:
|
if env_headers:
|
||||||
return [i.strip() for i in env_headers.split(",")]
|
return [i.strip() for i in env_headers.split(",")]
|
||||||
return v or ["Content-Type", "Authorization", "X-Requested-With"]
|
return v or ["Content-Type", "Authorization", "X-Requested-With", "X-API-Key", "Accept", "Origin"]
|
||||||
|
|
||||||
@field_validator("CORS_EXPOSE_HEADERS", mode="before")
|
@field_validator("CORS_EXPOSE_HEADERS", mode="before")
|
||||||
def assemble_cors_expose_headers(cls, v):
|
def assemble_cors_expose_headers(cls, v):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user