# How to redirect a websocket $connect on Serverless

**URL:** <https://forum.serverless.com/t/how-to-redirect-a-websocket-connect-on-serverless/12983>\
**Category:** Serverless Framework\
**Tags:** lambda, api-gateway\
**Created:** [October 30, 2020, 8:12pm UTC](https://forum.serverless.com/t/how-to-redirect-a-websocket-connect-on-serverless/12983 "2020-10-30T20:12:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![katesclau](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/katesclau/32/3687_2.png) [@katesclau](https://forum.serverless.com/u/katesclau)\
**Post date:** [October 30, 2020, 8:12pm UTC](https://forum.serverless.com/t/how-to-redirect-a-websocket-connect-on-serverless/12983/1 "2020-10-30T20:12:21Z")

</div>

Hey guys 🙋‍♂️, my first topic here - so please bear with me…

Context:  
We are building an API PROXY to centralize all services under the same domain and API GW.

Problem:  
I need to redirect a websocket $connect event to a legacy address

Solution?  
Lambda redirects with 301 and sends `Location` header

> ```
> exports.wsHandler = async (event, _context, _calllback) => {
> // Redirect URL
> return {
> statusCode: 301,
> headers: { 
> Location: 'wss://oldendpoint.com/subscriptions',
> },
> };
> }
> 
> ```

Problem again…  
No cors on API GW Websockets so I can tell it to accept `Location` header

Anyway I can explicit my API GW to accept the headers?

Thanks in advance 😊
