(req: $Request)
| 5 | import { getAppURLFactsFromRequestURL } from './urls.js'; |
| 6 | |
| 7 | function assertSecureRequest(req: $Request) { |
| 8 | const { https, proxy } = getAppURLFactsFromRequestURL(req.originalUrl); |
| 9 | |
| 10 | if (!https) { |
| 11 | return; |
| 12 | } |
| 13 | if ( |
| 14 | (proxy === 'none' && req.protocol !== 'https') || |
| 15 | (proxy === 'apache' && req.get('X-Forwarded-SSL') !== 'on') || |
| 16 | (proxy === 'aws' && req.get('X-Forwarded-Proto') !== 'https') |
| 17 | ) { |
| 18 | throw new Error('insecure request'); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | export { assertSecureRequest }; |
no test coverage detected