Skip to content

[bug]: Strapi client fail to initialize due to URL.canParse() method unavailable #95

@theophile-dotnet

Description

@theophile-dotnet

Bug Description

I'm encountouring an issue with strapi client, the console throw this error:
Could not initialize the Strapi Client

I figured out that using the strapi client library on typescript project leads to browser incompatibility with the URL.canParse() function. In my case it happens on "old" devices with different browsers and browser versions that are not supporting this method.

The solution to solve the problem is to use polyfills:
https://github.com/zloirock/core-js#url-and-urlsearchparams

Steps to Reproduce

  • Create an Angular 19 project
  • Install the strapi client library
  • Instanciate an instance of the strapi client
  • Browse to your app on an old browser that doesn't support URL.canParse() method

Expected Behavior

The method polyfill should be implemented into the library to prevent getting this error on old browsers versions.
Here is the list of browsers and the versions that supports the method:
https://developer.mozilla.org/en-US/docs/Web/API/URL/parse_static

Version

1.4.0

Operating System

Other

Runtime Environment

Browser

Logs

Media

Image

Confirmation Checklist

  • I have checked the existing issues
  • I agree to follow this project's Code of Conduct
  • I would like to work on this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugstatus: to be confirmedThe issue needs to be reproduced or confirmed by a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions