Skip to content

Can't refresh some pagesΒ #154

@Tockra

Description

@Tockra

Hello,

after I built my application in a docker container and run it there, I have problems while refreshing some pages.
I say some, because some pages can be reloaded, some pages not.
I've no idea why.

But the console message in my browser indicates that some variables in my auth provider are not set correctly. But I am very confused why.
It is caused by the env loading:

My provider:

"use client";

import React, { PropsWithChildren } from "react";

import { AuthProvider } from "react-oidc-context";

import { env } from "next-runtime-env";

export function AuthProviderWrapper({ children }: PropsWithChildren) {
  const NEXT_PUBLIC_AUTH_URL = env("NEXT_PUBLIC_AUTH_URL") ?? "";
  const NEXT_PUBLIC_AUTH_AUTHORITY_PATH =
    env("NEXT_PUBLIC_AUTH_AUTHORITY_PATH") ?? "";
  const NEXT_PUBLIC_AUTH_CLIENT_ID = env("NEXT_PUBLIC_AUTH_CLIENT_ID") ?? "";
  const NEXT_PUBLIC_AUTH_REDIRECT_URI =
    env("NEXT_PUBLIC_AUTH_REDIRECT_URI") ?? "";

  const oidcConfig = {
    authority: NEXT_PUBLIC_AUTH_URL + NEXT_PUBLIC_AUTH_AUTHORITY_PATH,
    client_id: NEXT_PUBLIC_AUTH_CLIENT_ID,
    redirect_uri: NEXT_PUBLIC_AUTH_REDIRECT_URI,
    loadUserInfo: true,
  };

  return <AuthProvider {...oidcConfig}>{children}</AuthProvider>;
}

I added some logging which says that after reload the page in the browser, my env("NEXT_PUBLIC_AUTH_URL") ?? ""(and all other calls) are evaluated to "" which causes my application to crash.
Only if I visit my main page (mydomain.de) everything is loaded fine again.
While navigation through the pages there is no issue.

Only on refresh the page. Maybe this is related with next-intl (???).

Does anybody has a hint how to fix that without removing the usage of next-runtime-env ?

T

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions