flusmic icon indicating copy to clipboard operation
flusmic copied to clipboard

[WEB] CORS error when accessing Entry API

Open apripy opened this issue 2 years ago • 1 comments

Describe the bug With flutter web, I get a CORS error when using flusmic to query Prismic.
This is because the Dio instance is instantiated with contentType: "application/json" (line 18 of flusmic_repository.dart), changing it to "text/plain" avoid the CORS error.

To Reproduce With flutter web:

    final flusmic = Flusmic(
        prismicEndpoint: 'https://your-repo-name.cdn.prismic.io/api/v2',
        defaultLanguage: s.localeName.toLowerCase().replaceAll("_", "-"));

    final response = await flusmic
        .query([Predicate.at(DefaultPredicatePath.id, 'legal_page')]);

Expected behavior Retrieves the result of the query

Environment info (flutter doctor) [✓] Flutter (Channel stable, 3.10.2, on macOS 13.2.1 22D68 darwin-arm64, locale fr-FR) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [✓] Chrome - develop for the web Chrome Version 113.0.5672.92 (arm64)

Using flusmic 4.0.1, no relevant dependencies override

apripy avatar May 26 '23 10:05 apripy

https://github.com/Andrea055/flusmic Fixed in my fork if you need

andreock avatar Jul 07 '23 09:07 andreock