{"message":"no Route matched with those values"}

14,846

when accessing the API from the other box using a webbrowser you didn't set the Host header. Since when using a webbrowser the browser will automatically set that header based on the url you type in the browser url bar.

remove the following element from the curl request to create the route:

--data 'hosts[]=supermarket.xxx.com'

Then it will only match on the path segment you provided and it should work

Share:
14,846
Saeed Gorbani
Author by

Saeed Gorbani

Updated on October 24, 2022

Comments

  • Saeed Gorbani
    Saeed Gorbani over 1 year

    I am new to Kong so bear with me:) I am hosting my APIs on a windows server as http://supermarket.xxxx.com:5000

    added service as follows on an Ubuntu box (http://supermarket.xxxx.com is added to hosts file)

     curl -i -X POST
     --url http://localhost:8001/services/
     --data 'name=SupermarketService'
     --data 'url=http://supermarket.xxx.com:5000'
    

    HTTP/1.1 201 Created Date: Thu, 17 Dec 2020 07:11:50 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Access-Control-Allow-Origin: * Server: kong/2.1.3 Content-Length: 379 X-Kong-Admin-Latency: 204

    2 Added the routes

    curl -i -X POST
    --url http://localhost:8001/services/SupermarketService/routes
    --data 'hosts[]=supermarket.xxx.com'
    --data 'paths[]=/api/categories'
    --data 'strip_path=false'
    --data 'methods[]=GET'
    

    HTTP/1.1 201 Created Date: Thu, 17 Dec 2020 09:01:17 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Access-Control-Allow-Origin: * Server: kong/2.1.3 Content-Length: 463 X-Kong-Admin-Latency: 11

    testing the setting on the Ubuntu box

    curl -i -X GET
    --url http://localhost:8000/api/categories
    --header 'Host: supermarket.xxx.com'
    

    HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Server: Microsoft-IIS/8.5 Strict-Transport-Security: max-age=31536000; includeSubDomains X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-UA-Compatible: IE=Edge,chrome=1 X-Xss-Protection: 1; mode=block Content-Security-Policy: default-src https: data: 'unsafe-inline' 'unsafe-eval' 'self' ; connect-src 'self' data: *; Date: Thu, 17 Dec 2020 23:10:21 GMT X-Kong-Upstream-Latency: 1586 X-Kong-Proxy-Latency: 2 Via: kong/2.1.3

    [{"id":100,"name":"Fruits and Vegetables"},{"id":101,"name":"Dairy"}]

    when I try to access the same API in another box using a web browser http://192.168.44.67:8000/api/categories //where 192.168.44.67 is the IP address of my Ubuntu box iI get this {"message":"no Route matched with those values"}

    Please let me know what is wrong.