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

Open
#95 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, typescript
Domain
api, frontend

Research direction

Start by reproducing the initialization failure in an Angular 19 project using an older browser without URL.canParse(). Check how the Strapi client initializes and how the documented core-js URL polyfill can be included. Done means the client initializes successfully on browsers lacking URL.canParse().

Written by the indexing model from the issue text.

Description

issue: bug source: client status: to be confirmed
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
Dominant language
TypeScript
Stars
83
Forks
18
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from strapi/client

All issues in strapi/client

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.