cloudflare / template-registry

A simple API via a Worker that serves all the template content
https://developers.cloudflare.com/workers/templates
Apache License 2.0
62 stars 37 forks source link

Use unescape instead of searchParams #27

Open fawazahmed0 opened 4 years ago

fawazahmed0 commented 4 years ago

-Fix apiurl with query string getting stripped Referred for code : https://github.com/Zibri/cloudflare-cors-anywhere/blob/2f5bae4c00bac89018e2ae7edc860ecba2a2223b/index.js#L48

fawazahmed0 commented 4 years ago

apiurl such as https://duckduckgo.com/?q=tro was getting stripped to https://duckduckgo.com/ Now it seems to work fine.

Just a question, I am not sure why the template doesn't work with google urls such as https://www.google.com/search?&q=marine All other sites url (except google) works fine though, not sure if this has something to do with template Update: using var instead of let for response variable , seems to solve the problem, and I don't think it has something to do with template Update2: var or let doesn't make any difference, it has to do with how the server responds, so no problem with the template

fawazahmed0 commented 4 years ago

Also it would be better to change line 13 to generalize the template Something like: // Setting CORS headers, we are allowing all the sites, you will have to limit this to specific sites in production response.headers.set('Access-Control-Allow-Origin', '*')