G4brym/R2-Explorer

TypeError: explorer.handle is not a function

clarencechien opened this issue · 2 comments

Hi, I follow the README to publish worker, but I got this error.
Is there a further manual or instruction to find out what's wrong?

note: wrangler 2.6.1
env: gitpod

Hey @clarencechien
There was a bug in the npx r2-explorer command, and I've just fixed it

To fix your current project, you just need to go to the src/index.js file and replace the return explorer.handle with just return explorer. And it should look like this:

import { R2Explorer } from 'r2-explorer';

const explorer = R2Explorer({ readonly: true })

export default {
  async fetch(request, env, context) {
    return explorer(request, env, context)
  }
};

You should also update your r2-explorer version to the latest using this command npm install --save r2-explorer@latest

New users running the npx command shouldn't have this problem from now onwards.

Let me know if you have any other problems and thanks for reporting the issue 😄

Hi @G4brym,

Thank you for quick response, this project is go great!
I follow your instruction, and now it works flawless.

I appreciate that you spent your time to work with this project.
Thank you so much for your generous sharing.
Have a nice day :)