mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
add useProxies config to support x-forwarded headers in express
This commit is contained in:
@@ -75,6 +75,10 @@ export function app() {
|
||||
*/
|
||||
const server = express();
|
||||
|
||||
// Tell Express to trust X-FORWARDED-* headers from proxies
|
||||
// See https://expressjs.com/en/guide/behind-proxies.html
|
||||
server.set('trust proxy', environment.ui.useProxies);
|
||||
|
||||
/*
|
||||
* If production mode is enabled in the environment file:
|
||||
* - Enable Angular's production mode
|
||||
|
@@ -10,6 +10,7 @@ describe('Config Util', () => {
|
||||
expect(appConfig.cache.msToLive.default).toEqual(15 * 60 * 1000); // 15 minute
|
||||
expect(appConfig.ui.rateLimiter.windowMs).toEqual(1 * 60 * 1000); // 1 minute
|
||||
expect(appConfig.ui.rateLimiter.max).toEqual(500);
|
||||
expect(appConfig.ui.useProxies).toEqual(true);
|
||||
|
||||
expect(appConfig.submission.autosave.metadata).toEqual([]);
|
||||
|
||||
@@ -25,6 +26,8 @@ describe('Config Util', () => {
|
||||
};
|
||||
appConfig.ui.rateLimiter = rateLimiter;
|
||||
|
||||
appConfig.ui.useProxies = false;
|
||||
|
||||
const autoSaveMetadata = [
|
||||
'dc.author',
|
||||
'dc.title'
|
||||
@@ -44,6 +47,7 @@ describe('Config Util', () => {
|
||||
expect(environment.cache.msToLive.default).toEqual(msToLive);
|
||||
expect(environment.ui.rateLimiter.windowMs).toEqual(rateLimiter.windowMs);
|
||||
expect(environment.ui.rateLimiter.max).toEqual(rateLimiter.max);
|
||||
expect(environment.ui.useProxies).toEqual(false);
|
||||
expect(environment.submission.autosave.metadata[0]).toEqual(autoSaveMetadata[0]);
|
||||
expect(environment.submission.autosave.metadata[1]).toEqual(autoSaveMetadata[1]);
|
||||
|
||||
|
@@ -37,7 +37,10 @@ export class DefaultAppConfig implements AppConfig {
|
||||
rateLimiter: {
|
||||
windowMs: 1 * 60 * 1000, // 1 minute
|
||||
max: 500 // limit each IP to 500 requests per windowMs
|
||||
}
|
||||
},
|
||||
|
||||
// Trust X-FORWARDED-* headers from proxies
|
||||
useProxies: true,
|
||||
};
|
||||
|
||||
// The REST API server settings
|
||||
|
@@ -11,4 +11,6 @@ export class UIServerConfig extends ServerConfig {
|
||||
max: number;
|
||||
};
|
||||
|
||||
// Trust X-FORWARDED-* headers from proxies
|
||||
useProxies: boolean;
|
||||
}
|
||||
|
@@ -25,7 +25,8 @@ export const environment: BuildConfig = {
|
||||
rateLimiter: {
|
||||
windowMs: 1 * 60 * 1000, // 1 minute
|
||||
max: 500 // limit each IP to 500 requests per windowMs
|
||||
}
|
||||
},
|
||||
useProxies: true,
|
||||
},
|
||||
|
||||
// The REST API server settings.
|
||||
|
Reference in New Issue
Block a user