Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sitecore-jss-proxy] Disable websocket processing by default in proxy #1311

Merged
merged 1 commit into from
Jan 31, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ export const config: ProxyConfig = {
* Default: 10MB
*/
maxResponseSizeBytes: 10 * 1024 * 1024,
/**
* Enables or disables proxy handling WebSocket connections
* Disabled by default - default JSS proxy logic doesn't handle WS requests and extra implementation is needed for WS to be processed.
*/
ws: false,
/**
* Options object for http-proxy-middleware. Consult its docs.
*/
Expand Down
4 changes: 4 additions & 0 deletions packages/sitecore-jss-proxy/src/ProxyConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export interface ProxyConfig {
* Mutually exclusive with pathRewriteExcludePredicate.
*/
pathRewriteExcludeRoutes?: string[];
/**
* Turn WebSocket requests processing on or off
*/
ws?: boolean;
/**
* Function to determine if a given URL should be SSRed (return true), or passed through (return false)
* Mutually exclusive with pathRewriteExcludeRoutes.
Expand Down
2 changes: 1 addition & 1 deletion packages/sitecore-jss-proxy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ function createOptions(
...config.proxyOptions,
target: config.apiHost,
changeOrigin: true, // required otherwise need to include CORS headers
ws: true,
ws: config.ws || false,
pathRewrite: (reqPath, req) => rewriteRequestPath(reqPath, req, config, parseRouteUrl),
logLevel: config.debug ? 'debug' : 'info',
onProxyReq: (proxyReq, req, res) =>
Expand Down