Link a Konnect Service to Insomnia
In Insomnia, link Konnect using a Personal Access Token (PAT) and set up proxy URLs for your Gateway Service.
Prerequisites
Kong Konnect
This is a Konnect tutorial and requires a Konnect personal access token.
-
Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.
-
Export your token to an environment variable:
export KONNECT_TOKEN='YOUR_KONNECT_PAT' -
Run the quickstart script to automatically provision a Control Plane and Data Plane, and configure your environment:
curl -Ls https://get.konghq.com/quickstart | bash -s -- -k $KONNECT_TOKEN --deck-outputThis sets up a Konnect Control Plane named
quickstart, provisions a local Data Plane, and prints out the following environment variable exports:export DECK_KONNECT_TOKEN=$KONNECT_TOKEN export DECK_KONNECT_CONTROL_PLANE_NAME=quickstart export KONNECT_CONTROL_PLANE_URL=https://us.api.konghq.com export KONNECT_PROXY_URL='http://localhost:8000'Copy and paste these into your terminal to configure your session.
decK v1.63.0+
To complete this tutorial, install decK. We recommend keeping decK up to date with the latest version (1.63.0).
decK is a CLI tool for managing Kong Gateway declaratively with state files.
This guide uses deck gateway apply, which directly applies entity configuration to your Gateway instance.
You can check your current decK version with deck version.
Required entities
For this tutorial, you’ll need Kong Gateway entities, like Gateway Services and Routes, pre-configured. These entities are essential for Kong Gateway to function but installing them isn’t the focus of this guide. Follow these steps to pre-configure them:
-
Run the following command:
echo ' _format_version: "3.0" services: - name: example-service url: http://httpbin.konghq.com/anything routes: - name: example-route paths: - "/anything" service: name: example-service protocols: - http - https ' | deck gateway apply -
To learn more about entities, you can read our entities documentation.
Link Insomnia to Konnect
- In your workspace, open the Konnect tab
- In the Personal Access Token, paste the PAT
- Click Connect & Sync
In your workspace, Insomnia now displays the Konnect tab. Open the tab and click Sync. After syncing, Insomnia displays your Kong Gateway Services under the Konnect
Set the Proxy URLs
On first Sync, set the proxy URL for each Gateway Service:
- From your Insomnia workspace, go to the Konnect tab
- Select a Gateway Service:
example-servicein this guide. - Open the Base Environment file
- Input the proxy URLs for the selected Gateway Service. For
example-service, setproxy_hosttolocalhost:8000
The proxy URLs depend on the type of control plane you chose. See Data Plane hosting options for details.
Insomnia never resets this setup when syncing. If you change the proxy URLs in Konnect, repeat this setup.
You are now ready to send requests from Insomnia against Routes hosted on Konnect.
Validate
- Select any Route from
example-service - Make sure the URL is
http://{{ _.proxy_host }}/anything - Click Send
In the Preview tab, Insomnia displays the following response:
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Connection": "keep-alive",
"Host": "httpbin.konghq.com",
"User-Agent": "insomnia/13.0.0-beta.0",
"X-Forwarded-Host": "localhost",
"X-Forwarded-Path": "/anything",
"X-Forwarded-Prefix": "/anything",
"X-Kong-Request-Id": "79f33a281e8c62316c922d0ab4fc0703"
},
"json": null,
"method": "GET",
"origin": "192.168.97.1",
"url": "http://localhost/anything"
}