Open benvandenberg opened 2 months ago
Hi @benvandenberg thanks for raising this issue. I'm going to mark it as a feature request for the team to consider.
Thank you @chrisbonifacio . The changes should look something close to https://github.com/aws-amplify/amplify-js/compare/main...benvandenberg:amplify-js:feature/appsync-proxy-endpoint
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
CDK
Environment information
Describe the bug
I am a platform developer, and working with a front end application that uses the amplify-js library to create subscriptions to AppSync.
We are running AppSync behind a reverse proxy: client -> ALB -> EC2 (NGINX) -> AppSync
The reverse proxy allows us to route requests through a single endpoint, which is important to our customers given their strict firewall rules.
I am able to write native code that let's a client create subscriptions to AppSync through the reverse proxy. However, our front end team uses the amplify-js library. I am unable to see a way to decouple the "host" from the request URL. When configuring the client, the "aws_appsync_graphqlEndpoint" value is used for both the host (the AppSync domain, used when setting up the websocket) and the destination of the request. In our case, we want the request to go to the URL assigned to the reverse proxy, but have the host value, used when setting up the websocket, be the AppSync domain.
Support for proxies was implemented as part of https://github.com/aws-amplify/amplify-js/commit/6d5afce390687e925438d6d208a18c84e61399a9, but does not work for subscriptions.
Expected behavior
The GraphQL API allows the customEndpoint to be set for subscriptions. The "host" should be the AppSync URL, while the requests should be sent to the custom endpoint.
Reproduction steps
Setup a reverse proxy using NGINX, and assign a URL to a Load Balancer.
Code Snippet
The location block of NGINX can be setup like this:
Log output
No response
aws-exports.js
No response
Manual configuration
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
I believe the fix should look something like this: https://github.com/aws-amplify/amplify-js/compare/main...benvandenberg:amplify-js:feature/appsync-proxy-endpoint