Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ api:
host: http://localhost
path: /otp/routers/default
port: 8001

# Support OTP-2 in parallel for certain requests
# api_v2:
# host: http://localhost
# path: /otp/routers/default
# port: 8002

# Add suggested locations to be shown as options in the form view.
# locations:
# - id: 'airport'
Expand Down
8 changes: 7 additions & 1 deletion lib/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,15 @@ function getOtpFetchOptions (state, includeToken = false) {
function constructRoutingQuery (state, ignoreRealtimeUpdates, injectedParams = {}) {
const { config, currentQuery } = state.otp
const routingType = currentQuery.routingType
const routingMode = injectedParams?.mode || currentQuery.mode

// Check for routingType-specific API config; if none, use default API
const rt = config.routingTypes && config.routingTypes.find(rt => rt.key === routingType)
const api = (rt && rt.api) || config.api

// Certain requests will require OTP-2. If an OTP-2 host is specified, set it to be used
const useOtp2 = !!config.api_v2 && routingMode.includes('FLEX')

const api = (rt && rt.api) || (useOtp2 && config.api_v2) || config.api
const planEndpoint = `${api.host}${api.port
? ':' + api.port
: ''}${api.path}/plan`
Expand Down