restructure some constants
This commit is contained in:
parent
3da302e35f
commit
8a1d12a218
@ -1,7 +1,8 @@
|
|||||||
export const PUBLIC_URL = process.env.NEXT_PUBLIC_URL as string;
|
export const PUBLIC_URL = process.env.NEXT_PUBLIC_URL as string;
|
||||||
export const SERVER_URL = process.env.SERVER_URL as string;
|
export const SERVER_URL = process.env.SERVER_URL as string;
|
||||||
export const API_URL = `${SERVER_URL}/api`;
|
export const API_URL = `${SERVER_URL}/api`;
|
||||||
export const OAUTH_URL = `${SERVER_URL}/oauth2`;
|
export const AUTHORIZE_URL = process.env.AUTHORIZE_URL as string;
|
||||||
|
export const TOKEN_URL = process.env.TOKEN_URL as string;
|
||||||
export const REDIRECT_URL = `${PUBLIC_URL}/api/callback`;
|
export const REDIRECT_URL = `${PUBLIC_URL}/api/callback`;
|
||||||
export const CLIENT_ID = process.env.CLIENT_ID as string;
|
export const CLIENT_ID = process.env.CLIENT_ID as string;
|
||||||
export const CLIENT_SECRET = process.env.CLIENT_SECRET as string;
|
export const CLIENT_SECRET = process.env.CLIENT_SECRET as string;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { API_URL, CLIENT_ID, CLIENT_SECRET, OAUTH_URL } from '../constants';
|
import { CLIENT_ID, CLIENT_SECRET, TOKEN_URL } from '../constants';
|
||||||
import { OAuth2TokenDto } from '../types/token-response.interface';
|
import { OAuth2TokenDto } from '../types/token-response.interface';
|
||||||
|
|
||||||
export async function fetchBearer<T>(
|
export async function fetchBearer<T>(
|
||||||
@ -16,7 +16,7 @@ export async function fetchBearer<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchToken(code: string): Promise<OAuth2TokenDto> {
|
export async function fetchToken(code: string): Promise<OAuth2TokenDto> {
|
||||||
return fetch(`${OAUTH_URL}/token`, {
|
return fetch(TOKEN_URL, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${Buffer.from(
|
Authorization: `Basic ${Buffer.from(
|
||||||
`${CLIENT_ID}:${CLIENT_SECRET}`
|
`${CLIENT_ID}:${CLIENT_SECRET}`
|
||||||
|
@ -3,7 +3,7 @@ const nextConfig = {
|
|||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
swcMinify: true,
|
swcMinify: true,
|
||||||
images: {
|
images: {
|
||||||
domains: ['localhost', '127.0.0.1', 'icynet.eu'],
|
domains: ['localhost', '127.0.0.1', 'secure.icynet.eu'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import Cookies from 'cookies';
|
import Cookies from 'cookies';
|
||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import {
|
import {
|
||||||
|
AUTHORIZE_URL,
|
||||||
CLIENT_ID,
|
CLIENT_ID,
|
||||||
COOKIE_KEYS,
|
COOKIE_KEYS,
|
||||||
OAUTH_URL,
|
|
||||||
REDIRECT_URL,
|
REDIRECT_URL,
|
||||||
} from '../../lib/constants';
|
} from '../../lib/constants';
|
||||||
import { encrypt, generateString } from '../../lib/utils/crypto';
|
import { encrypt, generateString } from '../../lib/utils/crypto';
|
||||||
@ -34,5 +34,5 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
signed: true,
|
signed: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
res.redirect(`${OAUTH_URL}/authorize?${params.toString()}`);
|
res.redirect(`${AUTHORIZE_URL}?${params.toString()}`);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ export const proxy = httpProxy.createProxyServer({
|
|||||||
* Get the actual back-end service url from env variables.
|
* Get the actual back-end service url from env variables.
|
||||||
* We shouldn't prefix the env variable with NEXT_PUBLIC_* to avoid exposing it to the client.
|
* We shouldn't prefix the env variable with NEXT_PUBLIC_* to avoid exposing it to the client.
|
||||||
*/
|
*/
|
||||||
|
changeOrigin: process.env.NODE_ENV === 'production',
|
||||||
target: process.env.SERVER_URL,
|
target: process.env.SERVER_URL,
|
||||||
autoRewrite: false,
|
autoRewrite: false,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user