diff --git a/.drone.yml b/.drone.yml index 78c490f8..472a3cd6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,11 +31,13 @@ steps: environment: NEXT_PUBLIC_API_HOST: https://pig.vault48.org/ NEXT_PUBLIC_REMOTE_CURRENT: https://pig.vault48.org/static/ + NEXT_PUBLIC_PUBLIC_HOST: https://vault48.org/ settings: dockerfile: docker/nextjs/Dockerfile build_args_from_env: - NEXT_PUBLIC_API_HOST - NEXT_PUBLIC_REMOTE_CURRENT + - NEXT_PUBLIC_PUBLIC_HOST tag: - ${DRONE_BRANCH} custom_labels: @@ -56,11 +58,13 @@ steps: environment: NEXT_PUBLIC_API_HOST: https://pig.staging.vault48.org/ NEXT_PUBLIC_REMOTE_CURRENT: https://pig.staging.vault48.org/static/ + NEXT_PUBLIC_PUBLIC_HOST: https://staging.vault48.org/ settings: dockerfile: docker/nextjs/Dockerfile build_args_from_env: - NEXT_PUBLIC_API_HOST - NEXT_PUBLIC_REMOTE_CURRENT + - NEXT_PUBLIC_PUBLIC_HOST tag: - ${DRONE_BRANCH} custom_labels: diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 30bb8fe7..29cdd904 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,5 +1,6 @@ import React from 'react'; +import App from 'next/app'; import Head from 'next/head'; import { PageCoverProvider } from '~/components/containers/PageCoverProvider'; @@ -9,6 +10,7 @@ import { MainLayout } from '~/containers/main/MainLayout'; import { DragDetectorProvider } from '~/hooks/dom/useDragDetector'; import { Sprites } from '~/sprites/Sprites'; import { getMOBXStore } from '~/store'; +import { CONFIG } from '~/utils/config'; import { StoreContextProvider } from '~/utils/context/StoreContextProvider'; import { UserContextProvider } from '~/utils/context/UserContextProvider'; import { AudioPlayerProvider } from '~/utils/providers/AudioPlayerProvider'; @@ -22,39 +24,47 @@ import '~/styles/main.scss'; const mobxStore = getMOBXStore(); -export default function MyApp({ Component, pageProps }) { - return ( - - - - - - - - - - - - +export default class MyApp extends App { + render() { + const { Component, pageProps, router } = this.props; + const canonicalURL = + !!CONFIG.publicHost && new URL(router.asPath, CONFIG.publicHost).toString(); - - - - - - - - - - - - - - - - - ); + return ( + + + + + + + + + + + + + {!!canonicalURL && } + + + + + + + + + + + + + + + + + + + ); + } } diff --git a/src/utils/config/index.ts b/src/utils/config/index.ts index 6b868a97..2e836055 100644 --- a/src/utils/config/index.ts +++ b/src/utils/config/index.ts @@ -1,7 +1,10 @@ export const CONFIG = { - apiHost: process.env.REACT_APP_API_HOST || process.env.NEXT_PUBLIC_API_HOST || '', - remoteCurrent: - process.env.REACT_APP_REMOTE_CURRENT || process.env.NEXT_PUBLIC_REMOTE_CURRENT || '', + // https://vault48.org/ by default + publicHost: process.env.NEXT_PUBLIC_PUBLIC_HOST, + // backend endpoint + apiHost: process.env.NEXT_PUBLIC_API_HOST || '', + // image storage endpoint (sames as backend, but with /static usualy) + remoteCurrent: process.env.NEXT_PUBLIC_REMOTE_CURRENT || '', // transitional prop, marks migration to nextjs isNextEnvironment: !!process.env.NEXT_PUBLIC_REMOTE_CURRENT || typeof window === 'undefined', };