Skip to content

Cannot load asset:// #2965

@antoniotorres

Description

@antoniotorres

Describe the bug

Trying to read a local file with fetch, but the request fails due to CORS error.

import { convertFileSrc } from "@tauri-apps/api/tauri";

...

const conv = convertFileSrc("DICOM_FILES/serie_0/IM0");
console.log(conv);
const test = await fetch(conv);
console.log(test);

To Reproduce

Steps to reproduce the behavior:

  1. yarn create tauri-app
  2. Create folder with static files inside src-tauri where the app is running
  3. Try to read the file

Expected behavior

Able to fetch to local file

Screenshots

image

Platform and Versions (required):

yarn tauri info
yarn run v1.22.10
warning package.json: No license field
warning ../package.json: No license field
$ tauri info
 app:spawn Running "/Users/antonio/tauri-app/node_modules/@tauri-apps/cli/bin/tauri-cli tauri info" +0ms


Operating System - Mac OS, version 12.0.1 X64

Node.js environment
  Node.js - 12.20.0
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 6.14.8
  yarn - 1.22.10

Rust environment
  rustc - 1.53.0
  cargo - 1.53.0

App directory structure
/dist
/node_modules
/src-tauri
/src

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src asset: blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - http://localhost:3000
  framework - React

✨  Done in 5.47s.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions