usrbinkat / lambda-langchain

MIT License
0 stars 0 forks source link

[bug] CORS Access-Control-Allowo-Origin header error #1

Open usrbinkat opened 11 months ago

usrbinkat commented 11 months ago

Problem

Possible root cause stemming from failure to properly configure and set value of AzureWebJobsStorage per AZ Console notification warnings.

Browser console error:

Access to fetch at 'https://app25ae4877.azurewebsites.net/api/langchain'
from origin
'https://account5ea009c9.z5.web.core.windows.net'
has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Browser error

image

usrbinkat commented 11 months ago

image

Attempt to disable cors is unsuccessful so far.

usrbinkat commented 11 months ago

attempting to resolve by adding api gateway in front of both endpoints.

usrbinkat commented 11 months ago

Current blocker:

~/Git/pulumi/langchain  main 9m 39s langchain ❯ pulumi destroy -y --refresh
Previewing destroy (azfunc)

View in Browser (Ctrl+O): https://app.pulumi.com/usrbinkat/t/azfunc/previews/1cfeed9d-6093-40e3-9fbb-331db5246ded

     Type                                     Name            Plan       
 -   pulumi:pulumi:Stack                      t-azfunc        delete     
 -   └─ azure-native:resources:ResourceGroup  resource-group  delete     

Resources:
    - 2 to delete

Destroying (azfunc)

View in Browser (Ctrl+O): https://app.pulumi.com/usrbinkat/t/azfunc/updates/30

     Type                                     Name            Status                            Info
 ~   pulumi:pulumi:Stack                      t-azfunc        **refreshing failed (0.00s)**     1 error
 -   └─ azure-native:resources:ResourceGroup  resource-group  **deleting failed**               1 error

Diagnostics:
  pulumi:pulumi:Stack (t-azfunc):
    error: update failed

  azure-native:resources:ResourceGroup (resource-group):
    error: Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=409 -- Original Error: Code="ResourceGroupDeletionBlocked" Message="Deletion of resource group 'resource-group49d4d1e9' failed as resources with identifiers 'Microsoft.ApiManagement/service/api-management-serviceb97beb42' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is 'b000fb38-398c-4184-9349-c0c937196821'. Please check audit logs for more details." Details=[{"message":"{\"error\":{\"code\":\"ServiceLocked\",\"message\":\"The API Service api-management-serviceb97beb42 is transitioning at this time. Please try the request again later.\",\"details\":null,\"innerError\":null}}","target":"/subscriptions/0282681f-7a9e-424b-80b2-96babd57a8a1/resourceGroups/resource-group49d4d1e9/providers/Microsoft.ApiManagement/service/api-management-serviceb97beb42"}]

Resources:

Duration: 9m39s
usrbinkat commented 11 months ago

Solved the delete and re-deployed to get the following result. I believe I broke the storage creation by mistake.

Will troubleshoot this next.

~/Git/pulumi/langchain  main 8s langchain ❯ pulumi up -y               
Updating (azfunc)

View in Browser (Ctrl+O): https://app.pulumi.com/usrbinkat/t/azfunc/updates/32

     Type                                                 Name                      Status                  Info
 +   pulumi:pulumi:Stack                                  t-azfunc                  **creating failed**     1 error
 +   ├─ azure-native:resources:ResourceGroup              resource-group            created (1s)            
 +   ├─ azure-native:web:AppServicePlan                   plan                      created (3s)            
 +   ├─ azure-native:apimanagement:ApiManagementService   api-management-service    created (4829s)         
 +   ├─ azure-native:storage:StorageAccount               account                   created (22s)           
 +   ├─ azure-native:storage:StorageAccountStaticWebsite  website                   created (0.97s)         
 +   ├─ azure-native:storage:BlobContainer                app-container             created (0.84s)         
 +   ├─ azure-native:storage:Blob                         app-blob                  created (1s)            
 +   └─ synced-folder:index:AzureBlobFolder               synced-folder             created (0.34s)         
 +      ├─ azure-native:storage:Blob                      synced-folder-index.html  created (1s)            
 +      └─ azure-native:storage:Blob                      synced-folder-error.html  created (1s)            

Diagnostics:
  pulumi:pulumi:Stack (t-azfunc):
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/Users/usrbinkat/Git/pulumi/langchain/__main__.py", line 65, in <lambda>
        lambda args: azure.storage.list_storage_account_service_sas(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: list_storage_account_service_sas() got an unexpected keyword argument 'ip'

Resources:
    + 11 created

Duration: 1h20m34s