Skip to content

Make header-generator compatible with Cloudflare workers (edge runtimes) #411

@labithiotis

Description

@labithiotis

Currently its not possible to use header-generator HeaderGenerator class inside Cloudflare workers as we get a the following error:

Error generating random headers with lib: ReferenceError: __dirname is not defined 

I would be nice to use this library inside Cloudflare workers (or other runtimes that don't have all of NodeJs's FS APIs).

Looking at the code there are two places which are causing this issue;

  1. Loading JSON files which could be resolved by adding resolveJsonModule to tsconfig.json.
    https://github.com/apify/fingerprint-suite/blob/master/packages/header-generator/src/header-generator.ts#L215
  2. Which is a tricky problem, is with passing in a string path to BayesianNetwork that uses another library called adm-zip, maybe this code can be made optional so it can work in Cloudflare workers??
    https://github.com/apify/fingerprint-suite/blob/master/packages/header-generator/src/header-generator.ts#L236

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions