Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug CORS issue on Safari when using Addressables to download asset bundles

Discussion in 'Unity Cloud Content Delivery' started by dhindman, Nov 1, 2023.

  1. dhindman

    dhindman

    Joined:
    Jan 28, 2016
    Posts:
    17
    I originally posted my issue in the Addressables forum here, but it may be that this is an issue with Cloud Content Delivery. Here is the content of my original post:

    My application first uses DownloadDependenciesAsync to cache all bundles which behaves as expected. The issue occurs when the application begins loading content and addressables attempts to load the cached bundles from indexedDB. It appears to be caused by a redirection that uses a disallowed value of "null" for the "Origin" header.

    This is not a problem on Chromium-based browsers nor Firefox.

    Unity version is 2022.3.6f1. Addressables version is 1.21.18.

    Here is the output from the JavaScript console showing the error:

    [Error] Cross-origin redirection to https://de0e87e1-8f47-43c2-8583-b55...ersionId=ac83ee12-481b-4c7e-a3f3-cbf6a4250b1a denied by Cross-Origin Resource Sharing policy: Origin null is not allowed by Access-Control-Allow-Origin. Status code: 307
    [Error] Fetch API cannot load https://de0e87e1-8f47-43c2-8583-b55...ripts_d395006de3657ac83f7e4ce3349a5bd8.bundle due to access control checks.
    [Error] Failed to load resource: Cross-origin redirection to https://de0e87e1-8f47-43c2-8583-b55...ersionId=ac83ee12-481b-4c7e-a3f3-cbf6a4250b1a denied by Cross-Origin Resource Sharing policy: Origin null is not allowed by Access-Control-Allow-Origin. Status code: 307 (content, line 0)
    [Log] [UnityCache] Failed to load 'https://de0e87e1-8f47-43c2-8583-b55...ripts_d395006de3657ac83f7e4ce3349a5bd8.bundle' from indexedDB cache due to the error: TypeError: Load failed (Wander.loader.js, line 1)

    Below is the output of the Headers section from the Network tab for this request:

    Summary
    URL: https://de0e87e1-8f47-43c2-8583-b55...ripts_d395006de3657ac83f7e4ce3349a5bd8.bundle
    URL: https://de0e87e1-8f47-43c2-8583-b55...ersionId=ac83ee12-481b-4c7e-a3f3-cbf6a4250b1a
    Status: —
    Source: —
    Initiator:
    Wander.loader.js:1:18001

    Request

    GET /client_api/v1/environments/staging/buckets/19e2890e-b97d-445d-a224-0b41325d6c7a/release_by_badge/UCB-35/entry_by_path/content/
    Accept: */*
    Origin: https://staging.wanderhere.org
    Referer: https://staging.wanderhere.org/
    Sec-Fetch-Dest: empty
    Sec-Fetch-Mode: cors
    Sec-Fetch-Site: cross-site
    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15

    Redirect Response

    307 Temporary Redirect
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: https://staging.wanderhere.org
    Access-Control-Expose-Headers: Content-Range,Location,Upload-Hash,Upload-Length,Upload-Offset,X-Authorization
    Date: Mon, 30 Oct 2023 15:35:50 GMT
    Expires: Tue, 31 Oct 2023 23:30:00 UTC
    Location: https://de0e87e1-8f47-43c2-8583-b55...ersionId=ac83ee12-481b-4c7e-a3f3-cbf6a4250b1a
    Vary: Origin

    Request

    Accept: */*
    Origin: null
    Referer: https://staging.wanderhere.org/
    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15

    Response

    No response headers

    Query String Parameters

    Location: /client_api/v1/environments/staging/buckets/19e2890e-b97d-445d-a224-0b41325d6c7a/releases/e38d75a1-d363-4adc-9410-9c05c33e904a/entry_by_path/content/?path=%2F6e1a9d9d7151092d875a90424da009f1_monoscripts_d395006de3657ac83f7e4ce3349a5bd8.bundle
    badgeName: UCB-35
    bucketId: 19e2890e-b97d-445d-a224-0b41325d6c7a
    entryId: 01774709-2636-447e-9c50-b26527a75508
    environment: staging
    filePath: 6e1a9d9d7151092d875a90424da009f1_monoscripts_d395006de3657ac83f7e4ce3349a5bd8.bundle
    releaseId: e38d75a1-d363-4adc-9410-9c05c33e904a
    serviceVersion: 1.7.2
    versionId: ac83ee12-481b-4c7e-a3f3-cbf6a4250b1a