Skip to content

Commit

Permalink
[Filing] Support both Secure/Plain websockets based on the App protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
meissadia committed Mar 28, 2022
1 parent 5ce5f4e commit 373b249
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ http {
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';

# CSP
add_header Content-Security-Policy "default-src 'self' blob:; script-src 'self' 'unsafe-inline' blob: data: https://tagmanager.google.com https://www.googletagmanager.com https://www.google-analytics.com https://*.cfpb.gov https://www.consumerfinance.gov; img-src 'self' blob: data: https://www.google-analytics.com https://raw.githubusercontent.com; style-src 'self' 'unsafe-inline'; font-src 'self' data:; object-src 'none'; frame-src 'self' https://www.youtube.com/ https://ffiec.cfpb.gov/; connect-src 'self' ws://*.cfpb.gov https://*.cfpb.gov https://www.consumerfinance.gov https://raw.githubusercontent.com https://ffiec-api.cfpb.gov https://ffiec.cfpb.gov https://*.mapbox.com https://www.google-analytics.com https://s3.amazonaws.com;";
add_header Content-Security-Policy "default-src 'self' blob:; script-src 'self' 'unsafe-inline' blob: data: https://tagmanager.google.com https://www.googletagmanager.com https://www.google-analytics.com https://*.cfpb.gov https://www.consumerfinance.gov; img-src 'self' blob: data: https://www.google-analytics.com https://raw.githubusercontent.com; style-src 'self' 'unsafe-inline'; font-src 'self' data:; object-src 'none'; frame-src 'self' https://www.youtube.com/ https://ffiec.cfpb.gov/; connect-src 'self' ws://*.cfpb.gov wss://*.cfpb.gov https://*.cfpb.gov https://www.consumerfinance.gov https://raw.githubusercontent.com https://ffiec-api.cfpb.gov https://ffiec.cfpb.gov https://*.mapbox.com https://www.google-analytics.com https://s3.amazonaws.com;";

# Restrict referrer
add_header Referrer-Policy "strict-origin";
Expand Down
2 changes: 2 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const App = () => {
<Route component={NotFound} />
</Switch>
{showFooter && <Footer config={config} />}
{console.log(window.location)
}
</AppContext.Provider>
)
}
Expand Down
4 changes: 3 additions & 1 deletion src/filing/actions/listenForProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ export default function listenForProgress() {
const wsBaseUrl = process.env.REACT_APP_ENVIRONMENT === 'CI'
? `${window.location.hostname}:8080`
: `${window.location.host}/v2/filing`

const socketType = window.location.protocol == 'https:' ? 'wss' : 'ws'

const wsProgressUrl = quarter
? `/institutions/${lei}/filings/${year}/quarter/${quarter}/submissions/${sequenceNumber}/progress`
: `/institutions/${lei}/filings/${year}/submissions/${sequenceNumber}/progress`

let socket = new WebSocket(`ws://${wsBaseUrl}${wsProgressUrl}`)
let socket = new WebSocket(`${socketType}://${wsBaseUrl}${wsProgressUrl}`)

socket.onopen = (event) => {
console.log('>>> Socket open! Listening for Progress...')
Expand Down

0 comments on commit 373b249

Please sign in to comment.