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

CORS issues making requests from Buf Studio #3281

Closed
hdevalence opened this issue Nov 3, 2023 · 8 comments · Fixed by #3296
Closed

CORS issues making requests from Buf Studio #3281

hdevalence opened this issue Nov 3, 2023 · 8 comments · Fixed by #3296
Assignees
Labels
_P-V1 Priority: slated for V1 release

Comments

@hdevalence
Copy link
Member

Describe the bug

CORS issues prevent Buf studio from making requests to the GRPC endpoints.

To Reproduce

https://buf.build/studio/penumbra-zone/penumbra/main/penumbra.core.component.shielded_pool.v1alpha1.QueryService/DenomMetadataById?target=https%3A%2F%2Fgrpc.testnet.penumbra.zone&selectedProtocol=grpc-web&share=swqq5lJQUEosLk4t8UxRslIAcYECmXl5qUVArpJHuJFroXFoVFiwU0lJfmh5aKa%2Bb2iJq3lRkVFoqLl%2BqIepgUFSZYG5v2OyrRJQby1XLQA

Fails in Firefox and iOS safari

Expected behavior

Making requests should just work

@conorsch conorsch self-assigned this Nov 3, 2023
@conorsch
Copy link
Contributor

conorsch commented Nov 3, 2023

Try again. I've implemented CORS headers on the grpc service for testnet, but not (yet) for preview:

❯ curl -I https://grpc.testnet.penumbra.zone
HTTP/2 200 
access-control-allow-credentials: true
access-control-allow-headers: accept,x-grpc-web,x-user-agent,content-type,user-agent
access-control-allow-origin: https://buf.build
content-type: application/grpc
date: Fri, 03 Nov 2023 22:50:43 GMT
grpc-status: 12
content-length: 0

❯ curl -I https://grpc.testnet-preview.penumbra.zone
HTTP/2 200 
content-type: application/grpc
date: Fri, 03 Nov 2023 22:50:46 GMT
grpc-status: 12
content-length: 0

You should therefore be able to use Buf Studio with the testnet grpc, but not with preview grpc. Can you confirm? Once the CORS config is solid, I'll add a PR to this repo to make sure it's always added, so it'll stick around, even on preview re-deploys.

@conorsch
Copy link
Contributor

conorsch commented Nov 3, 2023

Initial report shows working in Safari. I'm leaving this issue open as a reminder to update preview to match.

conorsch added a commit that referenced this issue Nov 6, 2023
Ensures that the ad-hoc changes made to the HTTPS reverse proxy fronting the
pd gRPC services persist. We want to ensure that the pd gRPC services is
usable with https://buf.build/studio/, and now it is.

Refs #3281.
conorsch added a commit that referenced this issue Nov 6, 2023
Ensures that the ad-hoc changes made to the HTTPS reverse proxy fronting the
pd gRPC services persist. We want to ensure that the pd gRPC services is
usable with https://buf.build/studio/, and now it is.

Refs #3281.
@conorsch
Copy link
Contributor

conorsch commented Nov 6, 2023

Headers are serving:

❯ curl -I https://grpc.testnet.penumbra.zone
HTTP/2 200 
access-control-allow-headers: accept,x-grpc-web,x-user-agent,content-type,user-agent
access-control-allow-origin: https://buf.build
content-type: application/grpc
date: Mon, 06 Nov 2023 22:35:23 GMT
grpc-status: 12
content-length: 0

❯ curl -I https://grpc.testnet-preview.penumbra.zone
HTTP/2 200 
access-control-allow-headers: accept,x-grpc-web,x-user-agent,content-type,user-agent
access-control-allow-origin: https://buf.build
content-type: application/grpc
date: Mon, 06 Nov 2023 22:35:26 GMT
grpc-status: 12
content-length: 0

via automatic deploy in https://github.com/penumbra-zone/penumbra/actions/runs/6777204344

@conorsch conorsch closed this as completed Nov 6, 2023
@hdevalence hdevalence reopened this Nov 8, 2023
@hdevalence
Copy link
Member Author

We don't want to special-case Buf Studio, we want GRPC to work from arbitrary web contexts.

@conorsch
Copy link
Contributor

conorsch commented Nov 8, 2023

Ah, I misunderstood. In that case, we'll want:

  • access-control-allow-origin: *
  • access-control-allow-methods: *

Which seems to have decent support cross-browser.

conorsch added a commit that referenced this issue Nov 8, 2023
conorsch added a commit that referenced this issue Nov 9, 2023
@hdevalence hdevalence reopened this Nov 15, 2023
@hdevalence
Copy link
Member Author

This is still broken. Steps to reproduce:

  1. pd testnet join
  2. pd start --home ... & cometbft start --home ...
  3. Set endpoint to http://localhost:8080 in Buf Studio
  4. Get "CORS Missing Allow Origin" (in Firefox, and presumably other browsers).

We can't fix this by special casing for Buf studio specifically or for the testnet infrastructure Penumbra Labs happens to run. The node software has to work out of the box.

@aubrika aubrika added P-next release _P-V1 Priority: slated for V1 release labels Nov 16, 2023
conorsch added a commit that referenced this issue Nov 22, 2023
We want to enable use of pd's gRPC services in arbitrary web contexts,
including between localhost and a published website, for debugging.
Refs #3281.
conorsch added a commit that referenced this issue Nov 22, 2023
We want to enable use of pd's gRPC services in arbitrary web contexts,
including between localhost and a published website, for debugging.
Refs #3281.
conorsch added a commit that referenced this issue Nov 22, 2023
We want to enable use of pd's gRPC services in arbitrary web contexts,
including between localhost and a published website, for debugging.
Refs #3281.
conorsch added a commit that referenced this issue Nov 22, 2023
We want to enable use of pd's gRPC services in arbitrary web contexts,
including between localhost and a published website, for debugging.
Refs #3281.
@conorsch
Copy link
Contributor

OK, we should be good to go here. I've added CORS support inside pd, and removed the RP middleware. When running locally, I'm able to use Buf Studio against http://localhost:8080 just fine, although for the SimulateTrade RPC to work, I have to provide --enable-expensive-rpc to pd start. I'm also able to run the same against https://grpc.testnet-preview.penumbra.zone, so I'm closing this issue, but don't hesitate to reopen if I've missed something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
_P-V1 Priority: slated for V1 release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants