Commit f3ecc07e authored by tom's avatar tom

auth route

parent caa24a4f
import { useRouter } from 'next/router';
import { route } from 'nextjs-routes';
import link from 'lib/link/link';
import appConfig from 'configs/app/config';
export default function useLoginUrl() {
const router = useRouter();
return link('auth', {}, { path: router.asPath });
return appConfig.authUrl + route({ pathname: '/auth', query: { path: router.asPath } });
}
......@@ -28,7 +28,8 @@ export default function link(
return paramValue ? `/${ paramValue }` : '';
});
const baseUrl = routeName === 'auth' ? appConfig.authUrl : appConfig.baseUrl;
// const baseUrl = routeName === 'auth' ? appConfig.authUrl : appConfig.baseUrl;
const baseUrl = appConfig.baseUrl;
const url = new URL(path, baseUrl);
......
......@@ -11,11 +11,10 @@ export type RouteName = keyof typeof ROUTES;
export const ROUTES = {
// NETWORK MAIN PAGE
// todo_tom need full url builder
network_index: {
pattern: PATHS.network_index,
crossNetworkNavigation: true,
},
// network_index: {
// pattern: PATHS.network_index,
// crossNetworkNavigation: true,
// },
// ACCOUNT
// watchlist: {
......@@ -43,10 +42,9 @@ export const ROUTES = {
// crossNetworkNavigation: true,
// },
// todo_tom need full url builder
tx: {
pattern: PATHS.tx,
},
// tx: {
// pattern: PATHS.tx,
// },
// BLOCKS
// blocks: {
......@@ -113,9 +111,10 @@ export const ROUTES = {
},
// AUTH
auth: {
pattern: PATHS.auth,
},
// todo_tom need add page to the app
// auth: {
// pattern: PATHS.auth,
// },
};
// !!! for development purpose only !!!
......
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import { route } from 'nextjs-routes';
import appConfig from 'configs/app/config';
import { NAMES } from 'lib/cookies';
import getCspPolicy from 'lib/csp/getCspPolicy';
import link from 'lib/link/link';
const cspPolicy = getCspPolicy();
......@@ -22,7 +22,7 @@ export function middleware(req: NextRequest) {
const apiToken = req.cookies.get(NAMES.API_TOKEN);
if ((isAccountRoute || isProfileRoute) && !apiToken && appConfig.isAccountSupported) {
const authUrl = link('auth', undefined, { path: req.nextUrl.pathname });
const authUrl = appConfig.authUrl + route({ pathname: '/auth', query: { path: req.nextUrl.pathname } });
return NextResponse.redirect(authUrl);
}
......
import type { NextPage } from 'next';
const AuthPage: NextPage = () => {
return null;
};
export default AuthPage;
export async function getServerSideProps() {
return {
notFound: true,
};
}
......@@ -18,6 +18,7 @@ declare module "nextjs-routes" {
| StaticRoute<"/api/proxy">
| DynamicRoute<"/apps/[id]", { "id": string }>
| StaticRoute<"/apps">
| StaticRoute<"/auth">
| StaticRoute<"/auth/profile">
| DynamicRoute<"/block/[height]", { "height": string }>
| StaticRoute<"/blocks">
......
import { Box, Center, useColorMode } from '@chakra-ui/react';
import { route } from 'nextjs-routes';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import type { AppItemOverview } from 'types/client/apps';
import appConfig from 'configs/app/config';
import link from 'lib/link/link';
import ContentLoader from 'ui/shared/ContentLoader';
import Page from 'ui/shared/Page/Page';
......@@ -26,9 +26,9 @@ const MarketplaceApp = ({ app, isLoading }: Props) => {
if (app && !isFrameLoading) {
const message = {
blockscoutColorMode: colorMode,
blockscoutRootUrl: link('network_index'),
blockscoutAddressExplorerUrl: link('address_index'),
blockscoutTransactionExplorerUrl: link('tx'),
blockscoutRootUrl: appConfig.baseUrl + route({ pathname: '/' }),
blockscoutAddressExplorerUrl: appConfig.baseUrl + route({ pathname: '/address/[id]', query: { id: '' } }),
blockscoutTransactionExplorerUrl: appConfig.baseUrl + route({ pathname: '/tx/[hash]', query: { hash: '' } }),
blockscoutNetworkName: appConfig.network.name,
blockscoutNetworkId: Number(appConfig.network.id),
blockscoutNetworkCurrency: appConfig.network.currency,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment