I have an Internal Apigee X Instance (not exposed on the internet) and facing problems in running "Try This API" on the Integrated Dev Portal. The Integrated Dev Portal is accessible on the internet.
The following are my settings:
1. Proxy is deployed on an Environment with Host name : prod.apigee.tcs.com and I'm able to invoke the proxy from a VM in the same GCP Project with the following curl command:
curl -i -k -H "Host: prod.apigee.tcs.com" https://xx.xxx.xx.x/tcs-apigee-demo-error-handling/transform-error/500/T05?apikey=xxx
2. I have set a CORS on the proxy with this configuration:
<CORS continueOnError="false" enabled="true" name="CORS-Allow">
<DisplayName>CORS-Allow</DisplayName>
<AllowOrigins>{request.header.origin}</AllowOrigins>
<AllowMethods>GET, PUT, POST, DELETE</AllowMethods>
<AllowHeaders>{substring(request.header.Access-Control-Request-Headers.values,1,-1)}</AllowHeaders>
<ExposeHeaders>*</ExposeHeaders>
<MaxAge>3628800</MaxAge>
<AllowCredentials>true</AllowCredentials>
<GeneratePreflightResponse>true</GeneratePreflightResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</CORS>
3. I have published the proxy with the following OAS spec which specifies the Host in the header
openapi: 3.0.0
info:
title: Error Handling
description: Error Handling Framework
contact:
email: xx@tcs.com
license:
name: TCS Confidential
url: xxx
version: 1.0.0
externalDocs:
description: TCS Apigee Developer Portal
url: https://xxx.apigee.io/
servers:
- url: https://xx.xxx.xx.xx/tcs-apigee-demo-error-handling
tags:
- name: transform-error
description: Trandform Error Messages
externalDocs:
description: Find out more
url: xx.apigee.io/
- name: passthru-error
description: Passthrough backend error meesages
externalDocs:
description: Find out more
url: xx.apigee.io/
security:
- api_key: []
paths:
/transform-error/{error_code}/{backend_id}:
get:
tags:
- transform
summary: Transform Backend Error Messages
description: Handle Backend Errors and transform error appropriately
operationId: transform-error
parameters:
- name: Host
in: header
description: Host Name
required: true
schema:
type: string
format: string
default: prod.apigee.tcs.com
- name: error_code
in: path
description: HTTP Status to be returned
required: true
schema:
type: integer
format: int64
- name: backend_id
in: path
description: Backend API Target Identifier
required: true
schema:
type: string
enum: ["T01","T02","T03","T04","T05"]
responses:
'200':
description: successful operation
'400':
description: a 400 error occured
'500':
description: a 500 error occured
/passthru-error/{error_code}/{backend_id}:
get:
tags:
- passthru
summary: Transform Backend Error Messages
description: Handle Backend Errors and transform error appropriately
operationId: passthru-error
parameters:
- name: Host
in: header
description: Host Name
required: true
schema:
type: string
format: string
default: prod.apigee.tcs.com
- name: error_code
in: path
description: HTTP Status to be returned
required: true
schema:
type: integer
format: int64
- name: backend_id
in: path
description: Backend API Target Identifier
required: true
schema:
type: string
enum: ["T01","T02","T03","T04","T05"]
responses:
'200':
description: successful operation
'400':
description: a 400 error occured
'500':
description: a 500 error occured
components:
securitySchemes:
api_key:
type: apiKey
name: apikey
in: query
When I run this from the Dev Portal, I get the following two errors in the console:
(1) Refused to set unsafe header "Host",
(2) xx.xxx.xx.x/tcs-apigee-demo-error-handling/transform-error/500/T05?apikey=abc Failed to load resource: net::ERR_CONNECTION_CLOSED
Is this because the IP address of the Apigee X instance is not externally exposed? Is there a way to use the Developer Portal "Try Out" on proxy hosted on Internal facing Apigee X instance ?
Thanks in advance !