Make sure you have the lastest version of Node and npm.
- Clone this repository.
- Rename
example.env
to.env
or create.env
and copy/paste text fromexample.env
- Create a free SerpApi account, if you haven't already.
- Copy your API key and paste it into your
.env
file. Configure your PORT number is desired. - Run
npm install
to install all dependencies. - (Optional) If using VSCode, install the REST Client extension. This is helpful for testing routes.
- Set the Access-Control-Allow-Origin header to the name of the domain you will be querying the proxy server from by editing line 15 of
server.js
:
app.use(cors({ origin: "http://yourdomain.com" }));
- Start the server by running
npm start
- You can now send requests to the proxy server and get back search results from SerpApi. The proxy server supports GET requests in the form of http://localhost:3000/search/?your-query-string and POST requests to http://localhost:3000/search with the search paramaters in the JSON body. You can also send a GET request with just a single keyword that will use hardcoded search parameters to http://localhost:3000/keyword-search/your-keyword.