Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forge/prime.worker.js 404 (Not Found) #1069

Closed
badasukerubin opened this issue Jan 6, 2024 · 0 comments
Closed

forge/prime.worker.js 404 (Not Found) #1069

badasukerubin opened this issue Jan 6, 2024 · 0 comments

Comments

@badasukerubin
Copy link

badasukerubin commented Jan 6, 2024

I faced this issue in my dev environment when I tried to generate a key pair asynchronously, the stack is Laravel + React (Vite).
I was able to solve this by doing the following:

// declare a variable to point to a public resource of the minified version of prime worker
const worker = `${window.location.origin}/workers/prime/prime.worker.min.js`;

pki.rsa.generateKeyPair(
      {
        bits: 2048,
        workers: 2,
        workerScript: worker,
      },
      ...
// package.json
// Automate the cp process; ensure to install copyfiles and also add to build.

  "scripts": {
    "copy-worker": "copyfiles -u 1 node_modules/node-forge/dist/prime.worker.min.js public/workers/prime/",
    "dev": "npm run copy-worker && vite",
    ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant