404 not found - virtual path

Hello,

I am trying to setup an endpoint with virtual path. when I am trying to hit the url, it is throwing 404 error.
GET: http://127.0.0.1:8080/test/list

API details:
{
“_id” : ObjectId(“59d383e40e6f5d0001046b2a”),
“name” : “test”,
“slug” : “test”,
“api_id” : “45277a5271764d557f4e9ebea586ef04”,
“org_id” : “59d37f6d0e6f5d0001046b22”,
“use_keyless” : true,
“use_oauth2” : false,
“use_openid” : false,
“openid_options” : {
“providers” : [],
“segregate_by_client” : false
},
“oauth_meta” : {
“allowed_access_types” : [],
“allowed_authorize_types” : [],
“auth_login_redirect” : “”
},
“auth” : {
“use_param” : false,
“param_name” : “”,
“use_cookie” : false,
“cookie_name” : “”,
“auth_header_name” : “”
},
“use_basic_auth” : false,
“enable_jwt” : false,
“use_standard_auth” : false,
“enable_coprocess_auth” : false,
“jwt_signing_method” : “”,
“jwt_source” : “”,
“jwt_identit_base_field” : “”,
“jwt_client_base_field” : “”,
“jwt_policy_field_name” : “”,
“notifications” : {
“shared_secret” : “”,
“oauth_on_keychange_url” : “”
},
“enable_signature_checking” : false,
“hmac_allowed_clock_skew” : -1.0,
“base_identity_provided_by” : “”,
“definition” : {
“location” : “header”,
“key” : “x-api-version”
},
“version_data” : {
“not_versioned” : true,
“versions” : {
“RGVmYXVsdA==” : {
“name” : “RGVmYXVsdA==”,
“expires” : “”,
“paths” : {
“ignored” : [],
“white_list” : [],
“black_list” : []
},
“use_extended_paths” : true,
“extended_paths” : {
“ignored” : [],
“white_list” : [],
“black_list” : [],
“cache” : [],
“transform” : [],
“transform_response” : [],
“transform_headers” : [],
“transform_response_headers” : [],
“hard_timeouts” : [],
“circuit_breakers” : [],
“url_rewrites” : [],
“virtual” : [
{
“response_function_name” : “sampleVirtual”,
“function_source_type” : “blob”,
“function_source_uri” : “ZnVuY3Rpb24gc2FtcGxlVmlydHVhbChyZXF1ZXN0LCBzZXNzaW9uLCBjb25maWcpIHsKICBsb2coIlZpcnR1YWwgVGVzdCBydW5uaW5nIikKCiAgbG9nKCJSZXF1ZXN0IEJvZHk6ICIpCiAgbG9nKHJlcXVlc3QuQm9keSkKCiAgbG9nKCJTZXNzaW9uOiAiKQogIGxvZyhzZXNzaW9uKQoKICBsb2coIkNvbmZpZzoiKQogIGxvZyhjb25maWcpCgogIGxvZygicGFyYW0tMToiKQogIGxvZyhyZXF1ZXN0LlBhcmFtc1sicGFyYW0xIl0pCgogIHZhciByZXNwb25zZU9iamVjdCA9IHsKICAgIEJvZHk6ICJUSElTIElTIEEgIFZJUlRVQUwgUkVTUE9OU0UiLAogICAgSGVhZGVyczogewogICAgICAidGVzdCI6ICJ2aXJ0dWFsIiwKICAgICAgInRlc3QtMiI6ICJ2aXJ0dWFsIgogICAgfSwKICAgIENvZGU6IDIwMAogIH0KCiAgcmV0dXJuIFR5a0pzUmVzcG9uc2UocmVzcG9uc2VPYmplY3QsIHNlc3Npb24ubWV0YV9kYXRhKQoKfQpsb2coIlZpcnR1YWwgVGVzdCBpbml0aWFsaXNlZCIp”,
“path” : “list”,
“method” : “GET”,
“use_session” : false
}
],
“size_limits” : [],
“method_transforms” : [],
“track_endpoints” : [],
“do_not_track_endpoints” : []
},
“global_headers” : {},
“global_headers_remove” : [],
“global_size_limit” : NumberLong(0),
“override_target” : “”
}
}
},
“uptime_tests” : {
“check_list” : [],
“config” : {
“expire_utime_after” : NumberLong(0),
“service_discovery” : {
“use_discovery_service” : false,
“query_endpoint” : “”,
“use_nested_query” : false,
“parent_data_path” : “”,
“data_path” : “”,
“port_data_path” : “”,
“target_path” : “”,
“use_target_list” : false,
“cache_timeout” : NumberLong(60),
“endpoint_returns_list” : false
},
“recheck_wait” : 0
}
},
“proxy” : {
“preserve_host_header” : false,
“listen_path” : “/test/”,
“target_url” : “http://httpbin.org/”,
“strip_listen_path” : true,
“enable_load_balancing” : false,
“target_list” : [],
“check_host_against_uptime_tests” : false,
“service_discovery” : {
“use_discovery_service” : false,
“query_endpoint” : “”,
“use_nested_query” : false,
“parent_data_path” : “”,
“data_path” : “hostname”,
“port_data_path” : “port”,
“target_path” : “/api-slug”,
“use_target_list” : false,
“cache_timeout” : NumberLong(60),
“endpoint_returns_list” : false
}
},
“disable_rate_limit” : false,
“disable_quota” : false,
“custom_middleware” : {
“pre” : [],
“post” : [],
“post_key_auth” : [],
“auth_check” : {
“name” : “”,
“path” : “”,
“require_session” : false
},
“response” : [],
“driver” : “”,
“id_extractor” : {
“extract_from” : “”,
“extract_with” : “”,
“extractor_config” : {}
}
},
“custom_middleware_bundle” : “”,
“cache_options” : {
“cache_timeout” : NumberLong(60),
“enable_cache” : true,
“cache_all_safe_requests” : false,
“cache_response_codes” : [],
“enable_upstream_cache_control” : false
},
“session_lifetime” : NumberLong(0),
“active” : true,
“auth_provider” : {
“name” : “”,
“storage_engine” : “”,
“meta” : {}
},
“session_provider” : {
“name” : “”,
“storage_engine” : “”,
“meta” : null
},
“event_handlers” : {
“events” : {}
},
“enable_batch_request_support” : false,
“enable_ip_whitelisting” : false,
“allowed_ips” : [],
“dont_set_quota_on_create” : false,
“expire_analytics_after” : NumberLong(0),
“response_processors” : [],
“CORS” : {
“enable” : false,
“allowed_origins” : [],
“allowed_methods” : [],
“allowed_headers” : [],
“exposed_headers” : [],
“allow_credentials” : false,
“max_age” : 24,
“options_passthrough” : false,
“debug” : false
},
“domain” : “”,
“do_not_track” : false,
“tags” : [],
“enable_context_vars” : false,
“config_data” : {},
“hook_references” : [],
“is_site” : false,
“sort_by” : 0
}

Hi,

Do you have any gateway logs for when you make the call?

Thanks
Josh - Tyk Support Team

time=“Oct 3 12:26:22” level=info msg=“Initiating reload”
time=“Oct 3 12:26:22” level=info msg=“Loading policies”
time=“Oct 3 12:26:22” level=info msg=“Using Policies from Dashboard Service”
time=“Oct 3 12:26:22” level=info msg=“Mutex lock acquired… calling”
time=“Oct 3 12:26:22” level=info msg=“Calling dashboard service for policy list”
time=“Oct 3 12:26:22” level=info msg=“Processing policy list”
time=“Oct 3 12:26:22” level=info msg=“Detected 7 APIs”
time=“Oct 3 12:26:22” level=info msg=“Preparing new router”
time=“Oct 3 12:26:22” level=info msg=“Initialising Tyk REST API Endpoints”
time=“Oct 3 12:26:22” level=info msg=“Loading API configurations.”
time=“Oct 3 12:26:22” level=info msg=“Tracking hostname” api_name=“Portal Assets” domain=www.tyk-portal-test.com
time=“Oct 3 12:26:22” level=info msg=“Tracking hostname” api_name=“Portal API” domain=www.tyk-portal-test.com
time=“Oct 3 12:26:22” level=info msg=“Tracking hostname” api_name=Portal domain=www.tyk-portal-test.com
time=“Oct 3 12:26:22” level=info msg=“Tracking hostname” api_name=test domain=“(no host)”
time=“Oct 3 12:26:22” level=info msg=“Tracking hostname” api_name=“Portal API” domain=www.tyk-portal-test.com
time=“Oct 3 12:26:22” level=info msg=“Loading API” api_name=Portal
time=“Oct 3 12:26:22” level=error msg=“Listen path collision, changed to /portal/-b94472e9785d44847029afa7dcf9f4ce” api_id=b94472e9785d44847029afa7dcf9f4ce org_id=59d37f530e6f5d0001046b1e
time=“Oct 3 12:26:22” level=info msg=“Checking security policy: Open” api_name=Portal
time=“Oct 3 12:26:22” level=info msg=“Loading API” api_name=“Portal Assets”
time=“Oct 3 12:26:22” level=error msg=“Listen path collision, changed to /portal-assets/-5089cfcc80494cc452985985e1a53c11” api_id=5089cfcc80494cc452985985e1a53c11 org_id=59d37f6d0e6f5d0001046b22
time=“Oct 3 12:26:22” level=info msg=“Checking security policy: Open” api_name=“Portal Assets”
time=“Oct 3 12:26:22” level=info msg=“Loading API” api_name=“Portal API”
time=“Oct 3 12:26:22” level=info msg=“Checking security policy: Open” api_name=“Portal API”
time=“Oct 3 12:26:22” level=info msg=“Loading API” api_name=test
time=“Oct 3 12:26:22” level=info msg=“Checking security policy: Open” api_name=test
time=“Oct 3 12:26:22” level=info msg=“Loading API” api_name=Portal
time=“Oct 3 12:26:22” level=error msg=“Listen path collision, changed to /portal/-dd21c1bc1ed844f27683b07a173c5b1f” api_id=dd21c1bc1ed844f27683b07a173c5b1f org_id=59d37f6d0e6f5d0001046b22
time=“Oct 3 12:26:22” level=info msg=“Checking security policy: Open” api_name=Portal
time=“Oct 3 12:26:22” level=info msg=“Loading API” api_name=“Portal API”
time=“Oct 3 12:26:22” level=info msg=“Checking security policy: Open” api_name=“Portal API”
time=“Oct 3 12:26:22” level=info msg=“Loading API” api_name=“Portal Assets”
time=“Oct 3 12:26:22” level=error msg=“Listen path collision, changed to /portal-assets/-4d56d7e6522a42d772652ed15df62965” api_id=4d56d7e6522a42d772652ed15df62965 org_id=59d37f530e6f5d0001046b1e
time=“Oct 3 12:26:22” level=info msg=“Checking security policy: Open” api_name=“Portal Assets”
time=“Oct 3 12:26:23” level=info msg=“Processed and listening on: /portal-assets/-4d56d7e6522a42d772652ed15df62965{rest:.}"
time=“Oct 3 12:26:23” level=info msg="Processed and listening on: /portal-assets/-5089cfcc80494cc452985985e1a53c11{rest:.
}”
time=“Oct 3 12:26:23” level=info msg=“Processed and listening on: /portal-api/{rest:.}"
time=“Oct 3 12:26:23” level=info msg="Processed and listening on: /portal/-b94472e9785d44847029afa7dcf9f4ce{rest:.
}”
time=“Oct 3 12:26:23” level=info msg=“Processed and listening on: /portal/-dd21c1bc1ed844f27683b07a173c5b1f{rest:.}"
time=“Oct 3 12:26:23” level=info msg="Processed and listening on: /test/{rest:.
}”
time=“Oct 3 12:26:23” level=info msg=“Processed and listening on: /api/{rest:.}"
time=“Oct 3 12:26:23” level=info msg=“Loading uptime tests…”
time=“Oct 3 12:26:23” level=info msg=“Initialised API Definitions”
time=“Oct 3 12:26:23” level=info msg=“API reload complete”
time=“Oct 3 12:26:23” level=info msg=“Initiating coprocess reload”
time=“Oct 3 12:33:58” level=info msg=“Reloading endpoints”
time=“Oct 3 12:33:58” level=info msg=“Reload queued”
time=“Oct 3 12:33:58” level=info msg=“Initiating reload”
time=“Oct 3 12:33:58” level=info msg=“Loading policies”
time=“Oct 3 12:33:58” level=info msg=“Using Policies from Dashboard Service”
time=“Oct 3 12:33:58” level=info msg=“Mutex lock acquired… calling”
time=“Oct 3 12:33:58” level=info msg=“Calling dashboard service for policy list”
time=“Oct 3 12:33:58” level=info msg=“Processing policy list”
time=“Oct 3 12:33:59” level=info msg=“Detected 6 APIs”
time=“Oct 3 12:33:59” level=info msg=“Preparing new router”
time=“Oct 3 12:33:59” level=info msg=“Initialising Tyk REST API Endpoints”
time=“Oct 3 12:33:59” level=info msg=“Loading API configurations.”
time=“Oct 3 12:33:59” level=info msg=“Tracking hostname” api_name=“Portal Assets” domain=www.tyk-portal-test.com
time=“Oct 3 12:33:59” level=info msg=“Tracking hostname” api_name=“Portal API” domain=www.tyk-portal-test.com
time=“Oct 3 12:33:59” level=info msg=“Tracking hostname” api_name=Portal domain=www.tyk-portal-test.com
time=“Oct 3 12:33:59” level=info msg=“Tracking hostname” api_name=“Portal API” domain=www.tyk-portal-test.com
time=“Oct 3 12:33:59” level=info msg=“Loading API” api_name=“Portal API”
time=“Oct 3 12:33:59” level=info msg=“Checking security policy: Open” api_name=“Portal API”
time=“Oct 3 12:33:59” level=info msg=“Loading API” api_name=Portal
time=“Oct 3 12:33:59” level=info msg=“Loading API” api_name=“Portal Assets”
time=“Oct 3 12:33:59” level=error msg=“Listen path collision, changed to /portal-assets/-4d56d7e6522a42d772652ed15df62965” api_id=4d56d7e6522a42d772652ed15df62965 org_id=59d37f530e6f5d0001046b1e
time=“Oct 3 12:33:59” level=info msg=“Checking security policy: Open” api_name=“Portal Assets”
time=“Oct 3 12:33:59” level=error msg=“Listen path collision, changed to /portal/-b94472e9785d44847029afa7dcf9f4ce” api_id=b94472e9785d44847029afa7dcf9f4ce org_id=59d37f530e6f5d0001046b1e
time=“Oct 3 12:33:59” level=info msg=“Loading API” api_name=“Portal Assets”
time=“Oct 3 12:33:59” level=error msg=“Listen path collision, changed to /portal-assets/-5089cfcc80494cc452985985e1a53c11” api_id=5089cfcc80494cc452985985e1a53c11 org_id=59d37f6d0e6f5d0001046b22
time=“Oct 3 12:33:59” level=info msg=“Checking security policy: Open” api_name=“Portal Assets”
time=“Oct 3 12:33:59” level=info msg=“Checking security policy: Open” api_name=Portal
time=“Oct 3 12:33:59” level=info msg=“Loading API” api_name=“Portal API”
time=“Oct 3 12:33:59” level=info msg=“Checking security policy: Open” api_name=“Portal API”
time=“Oct 3 12:33:59” level=info msg=“Loading API” api_name=Portal
time=“Oct 3 12:33:59” level=error msg=“Listen path collision, changed to /portal/-dd21c1bc1ed844f27683b07a173c5b1f” api_id=dd21c1bc1ed844f27683b07a173c5b1f org_id=59d37f6d0e6f5d0001046b22
time=“Oct 3 12:33:59” level=info msg=“Checking security policy: Open” api_name=Portal
time=“Oct 3 12:34:00” level=info msg="Processed and listening on: /portal-assets/-4d56d7e6522a42d772652ed15df62965{rest:.
}”
time=“Oct 3 12:34:00” level=info msg=“Processed and listening on: /portal-assets/-5089cfcc80494cc452985985e1a53c11{rest:.}"
time=“Oct 3 12:34:00” level=info msg="Processed and listening on: /portal-api/{rest:.
}”
time=“Oct 3 12:34:00” level=info msg=“Processed and listening on: /portal/-b94472e9785d44847029afa7dcf9f4ce{rest:.}"
time=“Oct 3 12:34:00” level=info msg="Processed and listening on: /portal/-dd21c1bc1ed844f27683b07a173c5b1f{rest:.
}”
time=“Oct 3 12:34:00” level=info msg=“Processed and listening on: /api/{rest:.}"
time=“Oct 3 12:34:00” level=info msg=“Loading uptime tests…”
time=“Oct 3 12:34:00” level=info msg=“Initialised API Definitions”
time=“Oct 3 12:34:00” level=info msg=“API reload complete”
time=“Oct 3 12:34:00” level=info msg=“Initiating coprocess reload”
time=“Oct 3 12:34:44” level=info msg=“Reloading endpoints”
time=“Oct 3 12:34:44” level=info msg=“Reload queued”
time=“Oct 3 12:34:44” level=info msg=“Initiating reload”
time=“Oct 3 12:34:44” level=info msg=“Loading policies”
time=“Oct 3 12:34:44” level=info msg=“Using Policies from Dashboard Service”
time=“Oct 3 12:34:44” level=info msg=“Mutex lock acquired… calling”
time=“Oct 3 12:34:44” level=info msg=“Calling dashboard service for policy list”
time=“Oct 3 12:34:44” level=info msg=“Processing policy list”
time=“Oct 3 12:34:44” level=info msg=“Detected 7 APIs”
time=“Oct 3 12:34:44” level=info msg=“Preparing new router”
time=“Oct 3 12:34:44” level=info msg=“Initialising Tyk REST API Endpoints”
time=“Oct 3 12:34:44” level=info msg=“Loading API configurations.”
time=“Oct 3 12:34:44” level=info msg=“Tracking hostname” api_name=“Portal Assets” domain=www.tyk-portal-test.com
time=“Oct 3 12:34:44” level=info msg=“Tracking hostname” api_name=“Portal API” domain=www.tyk-portal-test.com
time=“Oct 3 12:34:44” level=info msg=“Tracking hostname” api_name=Portal domain=www.tyk-portal-test.com
time=“Oct 3 12:34:44” level=info msg=“Tracking hostname” api_name=test domain=“(no host)”
time=“Oct 3 12:34:44” level=info msg=“Tracking hostname” api_name=“Portal API” domain=www.tyk-portal-test.com
time=“Oct 3 12:34:44” level=info msg=“Loading API” api_name=“Portal Assets”
time=“Oct 3 12:34:44” level=error msg=“Listen path collision, changed to /portal-assets/-4d56d7e6522a42d772652ed15df62965” api_id=4d56d7e6522a42d772652ed15df62965 org_id=59d37f530e6f5d0001046b1e
time=“Oct 3 12:34:44” level=info msg=“Checking security policy: Open” api_name=“Portal Assets”
time=“Oct 3 12:34:44” level=info msg=“Loading API” api_name=“Portal Assets”
time=“Oct 3 12:34:44” level=error msg=“Listen path collision, changed to /portal-assets/-5089cfcc80494cc452985985e1a53c11” api_id=5089cfcc80494cc452985985e1a53c11 org_id=59d37f6d0e6f5d0001046b22
time=“Oct 3 12:34:44” level=info msg=“Checking security policy: Open” api_name=“Portal Assets”
time=“Oct 3 12:34:44” level=info msg=“Loading API” api_name=“Portal API”
time=“Oct 3 12:34:44” level=info msg=“Checking security policy: Open” api_name=“Portal API”
time=“Oct 3 12:34:44” level=info msg=“Loading API” api_name=Portal
time=“Oct 3 12:34:44” level=error msg=“Listen path collision, changed to /portal/-b94472e9785d44847029afa7dcf9f4ce” api_id=b94472e9785d44847029afa7dcf9f4ce org_id=59d37f530e6f5d0001046b1e
time=“Oct 3 12:34:44” level=info msg=“Checking security policy: Open” api_name=Portal
time=“Oct 3 12:34:44” level=info msg=“Loading API” api_name=Portal
time=“Oct 3 12:34:44” level=error msg=“Listen path collision, changed to /portal/-dd21c1bc1ed844f27683b07a173c5b1f” api_id=dd21c1bc1ed844f27683b07a173c5b1f org_id=59d37f6d0e6f5d0001046b22
time=“Oct 3 12:34:44” level=info msg=“Checking security policy: Open” api_name=Portal
time=“Oct 3 12:34:44” level=info msg=“Loading API” api_name=test
time=“Oct 3 12:34:44” level=info msg=“Checking security policy: Open” api_name=test
time=“Oct 3 12:34:44” level=info msg=“Loading API” api_name=“Portal API”
time=“Oct 3 12:34:44” level=info msg=“Checking security policy: Open” api_name=“Portal API”
time=“Oct 3 12:34:45” level=info msg="Processed and listening on: /portal-assets/-4d56d7e6522a42d772652ed15df62965{rest:.
}”
time=“Oct 3 12:34:45” level=info msg=“Processed and listening on: /portal-assets/-5089cfcc80494cc452985985e1a53c11{rest:.}"
time=“Oct 3 12:34:45” level=info msg="Processed and listening on: /portal-api/{rest:.
}”
time=“Oct 3 12:34:45” level=info msg=“Processed and listening on: /portal/-b94472e9785d44847029afa7dcf9f4ce{rest:.}"
time=“Oct 3 12:34:45” level=info msg="Processed and listening on: /portal/-dd21c1bc1ed844f27683b07a173c5b1f{rest:.
}”
time=“Oct 3 12:34:45” level=info msg=“Processed and listening on: /test/{rest:.}"
time=“Oct 3 12:34:45” level=info msg="Processed and listening on: /api/{rest:.
}”
time=“Oct 3 12:34:45” level=info msg=“Loading uptime tests…”
time=“Oct 3 12:34:45” level=info msg=“Initialised API Definitions”
time=“Oct 3 12:34:45” level=info msg=“API reload complete”
time=“Oct 3 12:34:45” level=info msg=“Initiating coprocess reload”

I can’t see anything there relating to the 404’s but there are listen path collisions which might be resulting from you having multiple APIs with the same listen path.

Ok, so your config there looks OK, all the various things that could be causing a problem are al covered off.

Can you check your tyk.conf file to see whether you have "enable_jsvm": false, if you do, make it true, it could just be that the JS virtual machine is disabled.

enable_jsvm is true in tyk conf file.

When you make a request to the api, is there any corresponding log output? The middleware might be failing because of a syntax error.

Interestingly, if this API was being loaded by the gateway, you should be seeing a log line that says:

Virtual Test initialised

Because the code needs initialising by the gateway before being proxied.

You might want to check that the API you created actually proxies and works in general, does it send data to where it’s mean tto? A 404 usually means the APi is not loaded.