Skip to content

Commit

Permalink
NEXT_PUBLIC_LOGIN_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
frodehansen2 committed Dec 9, 2023
1 parent bce619f commit 8cec84f
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 43 deletions.
2 changes: 1 addition & 1 deletion apps/dine-pleiepenger/nais/dev-gcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"maxReplicas": 1,
"env": {
"NEXT_PUBLIC_BASE_PATH": "/dine-pleiepenger",
"NEXT_PUBLIC_LOGIN_URL": "https://dine-pleiepenger.intern.dev.nav.no/dine-pleiepenger/oauth2/login?redirect=/dine-pleiepenger",
"NEXT_PUBLIC_RUNTIME_ENVIRONMENT": "dev",
"NEXT_PUBLIC_API_URL_INNSYN": "http://sif-innsyn-api",
"NEXT_PUBLIC_API_URL_BRUKERDIALOG": "http://k9-brukerdialog-api",
"NEXT_PUBLIC_INNSYN_BACKEND_SCOPE": "dev-gcp:dusseldorf:sif-innsyn-api",
"NEXT_PUBLIC_BRUKERDIALOG_BACKEND_SCOPE": "dev-gcp:dusseldorf:k9-brukerdialog-api",
"NEXT_PUBLIC_IS_E2E": "false",
"NPM_CONFIG_CACHE": "/tmp",

"NEXT_PUBLIC_DINE_UTBETALINGER": "https://tjenester.nav.no/utbetalingsoversikt/",
Expand Down
3 changes: 1 addition & 2 deletions apps/dine-pleiepenger/nais/envs/.env.dev
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
NEXT_PUBLIC_INNSYN_BACKEND_SCOPE=dev-gcp:dusseldorf:sif-innsyn-api
NEXT_PUBLIC_BRUKERDIALOG_BACKEND_SCOPE=dev-gcp:dusseldorf:k9-brukerdialog-api
NEXT_PUBLIC_BASE_PATH=/dine-pleiepenger

NEXT_PUBLIC_LOGIN_URL=/dine-pleiepenger/oauth2/login?redirect=/dine-pleiepenger
NEXT_PUBLIC_RUNTIME_ENVIRONMENT=dev
NEXT_PUBLIC_API_URL_INNSYN=http://sif-innsyn-api
NEXT_PUBLIC_API_URL_BRUKERDIALOG=http://k9-brukerdialog-api
NEXT_PUBLIC_IS_E2E=false

# Innholdslenker
NEXT_PUBLIC_DINE_UTBETALINGER=https://tjenester.nav.no/utbetalingsoversikt/
Expand Down
3 changes: 1 addition & 2 deletions apps/dine-pleiepenger/nais/envs/.env.prod
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
NEXT_PUBLIC_INNSYN_BACKEND_SCOPE=prod-gcp:dusseldorf:sif-innsyn-api
NEXT_PUBLIC_BRUKERDIALOG_BACKEND_SCOPE=prod-gcp:dusseldorf:k9-brukerdialog-api
NEXT_PUBLIC_BASE_PATH=/familie/sykdom-i-familien/soknad/dine-pleiepenger

NEXT_PUBLIC_LOGIN_URL=https://www.nav.no/familie/sykdom-i-familien/soknad/dine-pleiepenger/oauth2/login?redirect=/familie/sykdom-i-familien/soknad/dine-pleiepenger
NEXT_PUBLIC_RUNTIME_ENVIRONMENT=production
NEXT_PUBLIC_API_URL_INNSYN=http://sif-innsyn-api
NEXT_PUBLIC_API_URL_BRUKERDIALOG=http://k9-brukerdialog-api
NEXT_PUBLIC_IS_E2E=false

# Innholdslenker
NEXT_PUBLIC_DINE_UTBETALINGER=https://tjenester.nav.no/utbetalingsoversikt/
Expand Down
2 changes: 1 addition & 1 deletion apps/dine-pleiepenger/nais/prod-gcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"maxReplicas": 2,
"env": {
"NEXT_PUBLIC_BASE_PATH": "/familie/sykdom-i-familien/soknad/dine-pleiepenger",
"NEXT_PUBLIC_LOGIN_URL": "https://www.nav.no/familie/sykdom-i-familien/soknad/dine-pleiepenger/oauth2/login?redirect=/familie/sykdom-i-familien/soknad/dine-pleiepenger",
"NEXT_PUBLIC_RUNTIME_ENVIRONMENT": "production",
"NEXT_PUBLIC_API_URL_INNSYN": "http://sif-innsyn-api",
"NEXT_PUBLIC_API_URL_BRUKERDIALOG": "http://k9-brukerdialog-api",
"NEXT_PUBLIC_INNSYN_BACKEND_SCOPE": "prod-gcp:dusseldorf:sif-innsyn-api",
"NEXT_PUBLIC_BRUKERDIALOG_BACKEND_SCOPE": "prod-gcp:dusseldorf:k9-brukerdialog-api",
"NEXT_PUBLIC_IS_E2E": "false",
"NPM_CONFIG_CACHE": "/tmp",

"NEXT_PUBLIC_DINE_UTBETALINGER": "https://tjenester.nav.no/utbetalingsoversikt/",
Expand Down
11 changes: 1 addition & 10 deletions apps/dine-pleiepenger/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const isE2E = process.env.NEXT_PUBLIC_IS_E2E === 'true';

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
Expand All @@ -19,17 +15,14 @@ const appDirectives = {
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: !isE2E ? 'standalone' : undefined,
output: 'standalone',
reactStrictMode: true,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
pageExtensions: ['page.tsx', 'api.ts'],
transpilePackages: ['tailwind-merge'],
experimental: {
optimizePackageImports: ['@navikt/aksel-icons', '@navikt/ds-react'],
},
typescript: {
ignoreBuildErrors: isE2E,
},
eslint: {
dirs: ['src'],
ignoreDuringBuilds: true,
Expand All @@ -40,8 +33,6 @@ const nextConfig = {
],

async headers() {
if (isE2E) return [];

const environment = process.env.NEXT_PUBLIC_RUNTIME_ENVIRONMENT === 'production' ? 'prod' : 'dev';
const cspValue = await buildCspHeader(appDirectives, { env: environment });

Expand Down
2 changes: 1 addition & 1 deletion apps/dine-pleiepenger/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export default defineConfig({
APPSTATUS_PROJECT_ID: 'ryujtq87',
APPSTATUS_DATASET: 'staging',
NEXT_PUBLIC_BASE_PATH: '/dine-pleiepenger',
NEXT_PUBLIC_LOGIN_URL: '/dine-pleiepenger/oauth2/login?redirect=/dine-pleiepenger',
NEXT_PUBLIC_RUNTIME_ENVIRONMENT: 'dev',
NEXT_PUBLIC_API_URL_INNSYN: 'http://sif-innsyn-api',
NEXT_PUBLIC_API_URL_BRUKERDIALOG: 'http://k9-brukerdialog-api',
NEXT_PUBLIC_INNSYN_BACKEND_SCOPE: 'dev-gcp:dusseldorf:sif-innsyn-api',
NEXT_PUBLIC_BRUKERDIALOG_BACKEND_SCOPE: 'dev-gcp:dusseldorf:k9-brukerdialog-api',
NEXT_PUBLIC_IS_E2E: 'false',
NPM_CONFIG_CACHE: '/tmp',
NEXT_PUBLIC_DINE_UTBETALINGER: 'https://tjenester.nav.no/utbetalingsoversikt/',
NEXT_PUBLIC_ENDRINGSDIALOG_URL: 'https://endringsmelding-pleiepenger.intern.dev.nav.no/',
Expand Down
4 changes: 2 additions & 2 deletions apps/dine-pleiepenger/src/auth/withAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function withAuthenticatedPage(handler: PageHandler = defaultPageHandler)
if (!bearerToken) {
return {
redirect: {
destination: `/oauth2/login?redirect=${getRedirectPath(context)}`,
destination: browserEnv.NEXT_PUBLIC_LOGIN_URL,
permanent: false,
basePath: false,
},
Expand All @@ -75,7 +75,7 @@ export function withAuthenticatedPage(handler: PageHandler = defaultPageHandler)
logger.error(error);
}
return {
redirect: { destination: `/oauth2/login?redirect=${getRedirectPath(context)}`, permanent: false },
redirect: { destination: browserEnv.NEXT_PUBLIC_LOGIN_URL, permanent: false },
};
}

Expand Down
24 changes: 4 additions & 20 deletions apps/dine-pleiepenger/src/pages/_document.page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { ReactElement } from 'react';
import { DecoratorComponents, fetchDecoratorReact } from '@navikt/nav-dekoratoren-moduler/ssr';
// This is imported to allow the Output File Tracing feature of Next.js to work correctly with the log patcher
import 'next-logger';

import React, { ReactElement } from 'react';
import Document, { DocumentContext, DocumentInitialProps, Head, Html, Main, NextScript } from 'next/document';
import { DecoratorComponents, fetchDecoratorReact } from '@navikt/nav-dekoratoren-moduler/ssr';

import { browserEnv, getServerEnv, isE2E } from '../utils/env';
import { browserEnv, getServerEnv } from '../utils/env';

// The 'head'-field of the document initialProps contains data from <head> (meta-tags etc)
const getDocumentParameter = (initialProps: DocumentInitialProps, name: string): string => {
Expand Down Expand Up @@ -87,18 +85,4 @@ class MyDocument extends Document<Props> {
}
}

class E2EDocument extends Document<Props> {
render(): React.JSX.Element {
return (
<Html lang="no">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}

export default isE2E ? E2EDocument : MyDocument;
export default MyDocument;
6 changes: 2 additions & 4 deletions apps/dine-pleiepenger/src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { z, ZodError } from 'zod';
export type PublicEnv = z.infer<typeof publicEnvSchema>;
export const publicEnvSchema = z.object({
NEXT_PUBLIC_BASE_PATH: z.string(),
NEXT_PUBLIC_LOGIN_URL: z.string(),
NEXT_PUBLIC_RUNTIME_ENVIRONMENT: z.union([z.string(), z.undefined()]),
NEXT_PUBLIC_API_URL_INNSYN: z.union([z.string(), z.undefined()]),
NEXT_PUBLIC_API_URL_BRUKERDIALOG: z.union([z.string(), z.undefined()]),
NEXT_PUBLIC_IS_E2E: z.union([z.string(), z.undefined()]),

/** Lenker */
NEXT_PUBLIC_DINE_UTBETALINGER: z.string(),
Expand Down Expand Up @@ -48,10 +48,10 @@ export const serverEnvSchema = z.object({
*/
export const browserEnv = publicEnvSchema.parse({
NEXT_PUBLIC_BASE_PATH: process.env.NEXT_PUBLIC_BASE_PATH,
NEXT_PUBLIC_LOGIN_URL: process.env.NEXT_PUBLIC_LOGIN_URL,
NEXT_PUBLIC_RUNTIME_ENVIRONMENT: process.env.NEXT_PUBLIC_RUNTIME_ENVIRONMENT,
NEXT_PUBLIC_API_URL_BRUKERDIALOG: process.env.NEXT_PUBLIC_API_URL_BRUKERDIALOG,
NEXT_PUBLIC_API_URL_INNSYN: process.env.NEXT_PUBLIC_API_URL_INNSYN,
NEXT_PUBLIC_IS_E2E: process.env.NEXT_PUBLIC_IS_E2E,
NEXT_PUBLIC_SAKBEHANDLINGSTID_INFO_URL: process.env.NEXT_PUBLIC_SAKBEHANDLINGSTID_INFO_URL,
NEXT_PUBLIC_SYKDOM_I_FAMILIEN_INFO_URL: process.env.NEXT_PUBLIC_SYKDOM_I_FAMILIEN_INFO_URL,
NEXT_PUBLIC_ETTERSENDELSE_PLEIEPENGER_URL: process.env.NEXT_PUBLIC_ETTERSENDELSE_PLEIEPENGER_URL,
Expand Down Expand Up @@ -109,5 +109,3 @@ export function getServerEnv(): ServerEnv & PublicEnv {
}

export const isLocal = process.env.NODE_ENV !== 'production';

export const isE2E = process.env.NEXT_PUBLIC_IS_E2E === 'true';

0 comments on commit 8cec84f

Please sign in to comment.