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

Workers Assets Binding #656

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BrandonDyer64
Copy link
Contributor

@BrandonDyer64 BrandonDyer64 commented Oct 18, 2024

closes #644

I went down a rabbit hole creating an entire new Assets env binding just to find out it's a Fetcher. In fact, you could probably use assets by just calling env.get_binding::<Fetcher>("ASSETS") without this PR.

TODO: Testing

@BrandonDyer64
Copy link
Contributor Author

BrandonDyer64 commented Oct 18, 2024

Maybe this isn't enough. I'm doing some testing and setting the following in my wrangler.toml will serve the assets, but not expose the binding:

[assets]
binding = "ASSETS"
directory = "./public/"

I get something along the lines of

Your worker has access to the following bindings:
- D1 Databases:
  - DB: anaso (00000000-0000-0000-0000-000000000000)
- Vars:
  - ANASO_JWT_SECRET: "################"

Nothing related to assets.

I'm on wrangler 3.81.0, worker-build 0.1.0, and compatibility_date = "2024-09-19".

@kflansburg
Copy link
Member

Sorry that you went in circles on this. I think this looks correct. Have you tried deploying your worker and testing that? I will see if I can reproduce the issue in local development.

@kflansburg
Copy link
Member

This worked locally for me. You do need to specify a dummy URL (I think all Fetchers behave this way).

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

Successfully merging this pull request may close these issues.

Introduce Workers Assets binding
2 participants