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

No query string was present #71

Closed
StarpTech opened this issue Aug 7, 2021 · 5 comments
Closed

No query string was present #71

StarpTech opened this issue Aug 7, 2021 · 5 comments

Comments

@StarpTech
Copy link

StarpTech commented Aug 7, 2021

Fail with No query string was present in the browser but works with CURL

https://gitlab.fastgraph.de?query={__typename}&extensions={%22persistedQuery%22:{%22version%22:1,%22sha256Hash%22:%22ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38%22}}

CURL

curl --request GET \
  --url 'https://gitlab.fastgraph.de?query=%7B__typename%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38%22%7D%7D' \
  --header 'Accept-Encoding: br' \
  --header 'Content-Type: application/json' \
  --data '{"query":""}'

Source: https://github.com/StarpTech/FastGraph/blob/main/src/routes/apq.ts

@lukeed
Copy link
Owner

lukeed commented Aug 7, 2021

This is not a worktop issue. As mentioned to you in private chat, this is a known issue about Cloudflare Workers specifically. See here for workaround. Worktop correctly parses & exposes the query parameters, but only if it can access them from CFW directly.


Edit: Including screenshot of tweet since Twitter seems to be having issues loading it (today?)

Screen Shot 2021-08-07 at 1 17 06 PM

@lukeed lukeed closed this as completed Aug 7, 2021
@StarpTech
Copy link
Author

Please have a closer look. The referenced issue is related to a collision with two workers. I have only one and I also tried a different prefix without success.

See here

The URL doesn't work.

@lukeed
Copy link
Owner

lukeed commented Aug 7, 2021

No, the issue linked is exactly relevant to what you're describing. A querystring is only passed to a worker endpoint if it has a route that ends in *

This is not a worktop issue. You will find the same problem with a 5-line plain worker script:

addEventListener('fetch', event => {
  event.respondWith(
    new Response(event.request.url)
  );
});

The query string only shows up with the correct route in place.

@StarpTech
Copy link
Author

StarpTech commented Aug 7, 2021

No, the issue linked is exactly relevant to what you're describing. A querystring is only passed to a worker endpoint if it has a route that ends in *

I have a route that ends with *.

https://gitlab.fastgraph.de/*

@lukeed
Copy link
Owner

lukeed commented Aug 7, 2021

You need to add a route that has * at the end of the path that you want to accept querystrings on, as the tweet says.

So, for your example, you want to add querystrings to the /query path, so you need to add a route for your worker:

https://gitlab.fastgraph.de/query*

Until you do that you will never see query strings on any /query requests.

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

2 participants