Managed app not using bundled asset and getting access denied from cloudfront

After building on EAS for iOS using profile production, my SVG asset is failing to load. It appears to be failing to load from cloud front, but the asset is locally bundled.

Unfortunately, if I do a dev-client build the asset loads. I only see this problem with a full production build.

I downloaded the IPA from EAS and can see the asset in the package.

Contents of the asset in production according to Sentry

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>1AG9BA8T0A244909</RequestId><HostId>JpVv+xOMRTepEDplL2LjIkKXx6fnbpYPBsokJHjUO56eqPo+bJcyAwMNqUHKou+fJscAuZlhGts=</HostId></Error>

In my config

packagerOpts: {
    assetExts: ["min.svg"]
  },

Usage

const svg = require("../../assets/svg/table.min.svg")

async function fetchLocalFile(setState) {
  const file = Asset.fromModule(svg)
  await file.downloadAsync() // Optional, saves file into cache
  const asset = await fetch(file.uri)
  const contents = await asset.text()

  setState(contents);
}

What else should I be looking at? I’ve been scouring the docs trying to understand why this error is happening and what request is being made that is failing.

Figured it out,

const asset = await fetch(file.uri)

should be

const asset = await fetch(file.localUri)

looks like uri is populated even if the asset was never uploaded to https://classic-assets.eascdn.net/

Ok, so that worked with iOS but Android shows null for

const file = Asset.fromModule(svg)
const asset = await fetch(file.localUri)

throws an exception on Android.

Instead use

await FileSystem.readAsStringAsync(file.localUri);

Hi @grossadamm

What are you doing with contents after that?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.