Skip to content

Commit 439f3c2

Browse files
committed
Fix redirect, igjen
1 parent d0788a7 commit 439f3c2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

legacy-archive/server/src/cms/CmsArchiveSite.ts

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ type ContructorProps = {
2121
htmlRenderer: HtmlRenderer;
2222
};
2323

24+
const HOST_SUFFIX_INTERNAL = 'intern.nav.no';
25+
const HOST_SUFFIX_EXTERNAL = 'ansatt.nav.no';
26+
2427
export class CmsArchiveSite {
2528
private readonly config: LegacyArchiveSiteConfig;
2629
private readonly pdfGenerator: PdfGenerator;
@@ -116,6 +119,13 @@ export class CmsArchiveSite {
116119
router.get('/:versionKey?', cspMiddleware, async (req, res) => {
117120
const rootCategories = this.categoriesService.getRootCategories();
118121

122+
const { hostname, protocol, baseUrl } = req;
123+
124+
if (hostname.endsWith(HOST_SUFFIX_INTERNAL)) {
125+
const externalUrl = `${protocol}://${hostname.replace(HOST_SUFFIX_INTERNAL, HOST_SUFFIX_EXTERNAL)}${baseUrl}`;
126+
return res.redirect(externalUrl);
127+
}
128+
119129
const appContext = {
120130
rootCategories,
121131
selectedVersionKey: req.params.versionKey,

legacy-archive/server/src/routing/site.ts

-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ export const setupSites = async (expressApp: Express) => {
2121
args: ['--no-sandbox', '--disable-setuid-sandbox', '--user-data-dir=/tmp/.chromium'],
2222
});
2323

24-
expressApp.all('/:cms/:versionId?', (req, res, next) => {
25-
if (req.hostname.endsWith('intern.nav.no')) {
26-
return res.redirect(req.url.replace('intern.nav.no', 'ansatt.nav.no'));
27-
}
28-
29-
return next();
30-
});
31-
3224
const sites = legacyArchiveConfigs.map((config) => {
3325
return new CmsArchiveSite({
3426
config,

0 commit comments

Comments
 (0)