Using california for a test search as you did, I still see status 406
. The URL is (formatted for readability)
https://letsgoparty.netlify.app/search
?q=california&engine=google_events
&htichips=&start=0&source=nodejs&output=json
&api_key=348e8db09351ac50bd0d138aa02fa794c792d94070d5fc3a628ea00c94025b64
First thing to note is the api_key
is embedded in it. If you wish to keep information private I suggest reading [Support Guide] How do I keep my API keys/tokens safe using Netlify Functions?
I see from the repository and an early post a proxy redirect
Using this URL in place of that of your Netlify URL yields
https://serpapi.com/?q=california&engine=google_events
&htichips=&start=0&source=nodejs&output=json
&api_key=348e8db09351ac50bd0d138aa02fa794c792d94070d5fc3a628ea00c94025b64
Following this in a browser returns the SerpApi homepage. Why? Because the redirect URL is missing the /search
path. This is how it should look
https://serpapi.com/search?q=california&engine=google_events
&htichips=&start=0&source=nodejs&output=json
&api_key=348e8db09351ac50bd0d138aa02fa794c792d94070d5fc3a628ea00c94025b64
As mentioned here query parameters are automatically pass through. So to get it working properly change the above redirect to
[[redirects]]
from = "/search"
to = "https://serpapi.com/search"
status = 200
headers = { Access-Control-Allow-Origin = "*" }
(I tested this locally and it works correctly.)