fix: usage of API_URL
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| COMPOSE_PROJECT_NAME='thream-api' | ||||
| HOST='0.0.0.0' | ||||
| PORT='8080' | ||||
| API_URL='http://localhost:8080' | ||||
| DATABASE_URL='postgresql://user:password@thream-database:5432/thream' | ||||
| JWT_ACCESS_EXPIRES_IN='15 minutes' | ||||
| JWT_ACCESS_SECRET='accessTokenSecret' | ||||
|   | ||||
							
								
								
									
										5
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							| @@ -32,11 +32,6 @@ jobs: | ||||
|       - name: 'Build' | ||||
|         run: 'npm run build' | ||||
|  | ||||
|       - name: 'Production migration' | ||||
|         run: 'npm run prisma:migrate:deploy' | ||||
|         env: | ||||
|           DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||||
|  | ||||
|       - name: 'Release' | ||||
|         run: 'npm run release' | ||||
|         env: | ||||
|   | ||||
| @@ -8,7 +8,7 @@ import { fastifyErrors } from '../../../models/utils.js' | ||||
| import authenticateUser from '../../../tools/plugins/authenticateUser.js' | ||||
| import { userCurrentSchema, userSchema } from '../../../models/User.js' | ||||
| import { sendEmail } from '../../../tools/email/sendEmail.js' | ||||
| import { HOST, PORT } from '../../../tools/configurations/index.js' | ||||
| import { API_URL } from '../../../tools/configurations/index.js' | ||||
| import { Language, Theme } from '../../../models/UserSettings.js' | ||||
| import { parseStringNullish } from '../../../tools/utils/parseStringNullish.js' | ||||
|  | ||||
| @@ -109,7 +109,7 @@ export const putCurrentUser: FastifyPluginAsync = async (fastify) => { | ||||
|         await sendEmail({ | ||||
|           type: 'confirm-email', | ||||
|           email, | ||||
|           url: `${request.protocol}://${HOST}:${PORT}/users/confirm-email?temporaryToken=${temporaryToken}${redirectQuery}`, | ||||
|           url: `${API_URL}/users/confirm-email?temporaryToken=${temporaryToken}${redirectQuery}`, | ||||
|           language: settings.language as Language, | ||||
|           theme: settings.theme as Theme | ||||
|         }) | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { HOST, PORT } from '../../../../../tools/configurations/index.js' | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
| import { discordStrategy, getDiscordUserData } from '../__utils__/utils.js' | ||||
| import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js' | ||||
| @@ -37,7 +37,7 @@ export const getCallbackDiscordOAuth2Service: FastifyPluginAsync = async ( | ||||
|       const { redirectURI, code } = request.query | ||||
|       const discordUser = await getDiscordUserData( | ||||
|         code, | ||||
|         `${request.protocol}://${HOST}:${PORT}/users/oauth2/discord/callback?redirectURI=${redirectURI}` | ||||
|         `${API_URL}/users/oauth2/discord/callback?redirectURI=${redirectURI}` | ||||
|       ) | ||||
|       const responseJWT = await discordStrategy.callbackSignin({ | ||||
|         name: discordUser.username, | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { HOST, PORT } from '../../../../../tools/configurations/index.js' | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
| import { DISCORD_BASE_URL, DISCORD_CLIENT_ID } from '../__utils__/utils.js' | ||||
|  | ||||
| @@ -33,7 +33,7 @@ export const getSigninDiscordOAuth2Service: FastifyPluginAsync = async ( | ||||
|     schema: getServiceSchema, | ||||
|     handler: async (request, reply) => { | ||||
|       const { redirectURI } = request.query | ||||
|       const redirectCallback = `${request.protocol}://${HOST}:${PORT}/users/oauth2/discord/callback?redirectURI=${redirectURI}` | ||||
|       const redirectCallback = `${API_URL}/users/oauth2/discord/callback?redirectURI=${redirectURI}` | ||||
|       const url = `${DISCORD_BASE_URL}/oauth2/authorize?client_id=${DISCORD_CLIENT_ID}&scope=identify&response_type=code&redirect_uri=${redirectCallback}` | ||||
|       reply.statusCode = 200 | ||||
|       return url | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { HOST, PORT } from '../../../../../tools/configurations/index.js' | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
| import { githubStrategy, getGitHubUserData } from '../__utils__/utils.js' | ||||
| import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js' | ||||
| @@ -37,7 +37,7 @@ export const getCallbackGitHubOAuth2Service: FastifyPluginAsync = async ( | ||||
|       const { redirectURI, code } = request.query | ||||
|       const githubUser = await getGitHubUserData( | ||||
|         code, | ||||
|         `${request.protocol}://${HOST}:${PORT}/users/oauth2/github/callback?redirectURI=${redirectURI}` | ||||
|         `${API_URL}/users/oauth2/github/callback?redirectURI=${redirectURI}` | ||||
|       ) | ||||
|       const responseJWT = await githubStrategy.callbackSignin({ | ||||
|         name: githubUser.name, | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { HOST, PORT } from '../../../../../tools/configurations/index.js' | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
| import { GITHUB_BASE_URL, GITHUB_CLIENT_ID } from '../__utils__/utils.js' | ||||
|  | ||||
| @@ -33,7 +33,7 @@ export const getSigninGitHubOAuth2Service: FastifyPluginAsync = async ( | ||||
|     schema: getServiceSchema, | ||||
|     handler: async (request, reply) => { | ||||
|       const { redirectURI } = request.query | ||||
|       const redirectCallback = `${request.protocol}://${HOST}:${PORT}/users/oauth2/github/callback?redirectURI=${redirectURI}` | ||||
|       const redirectCallback = `${API_URL}/users/oauth2/github/callback?redirectURI=${redirectURI}` | ||||
|       const url = `${GITHUB_BASE_URL}/login/oauth/authorize?client_id=${GITHUB_CLIENT_ID}&redirect_uri=${redirectCallback}` | ||||
|       reply.statusCode = 200 | ||||
|       return url | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { HOST, PORT } from '../../../../../tools/configurations/index.js' | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
| import { googleStrategy, getGoogleUserData } from '../__utils__/utils.js' | ||||
| import { buildQueryURL } from '../../../../../tools/utils/buildQueryURL.js' | ||||
| @@ -37,7 +37,7 @@ export const getCallbackGoogleOAuth2Service: FastifyPluginAsync = async ( | ||||
|       const { redirectURI, code } = request.query | ||||
|       const googleUser = await getGoogleUserData( | ||||
|         code, | ||||
|         `${request.protocol}://${HOST}:${PORT}/users/oauth2/google/callback?redirectURI=${redirectURI}` | ||||
|         `${API_URL}/users/oauth2/google/callback?redirectURI=${redirectURI}` | ||||
|       ) | ||||
|       const responseJWT = await googleStrategy.callbackSignin({ | ||||
|         name: googleUser.name, | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import { Static, Type } from '@sinclair/typebox' | ||||
| import { FastifyPluginAsync, FastifySchema } from 'fastify' | ||||
|  | ||||
| import { HOST, PORT } from '../../../../../tools/configurations/index.js' | ||||
| import { API_URL } from '../../../../../tools/configurations/index.js' | ||||
| import { fastifyErrors } from '../../../../../models/utils.js' | ||||
| import { GOOGLE_BASE_URL, GOOGLE_CLIENT_ID } from '../__utils__/utils.js' | ||||
|  | ||||
| @@ -33,7 +33,7 @@ export const getSigninGoogleOAuth2Service: FastifyPluginAsync = async ( | ||||
|     schema: getServiceSchema, | ||||
|     handler: async (request, reply) => { | ||||
|       const { redirectURI } = request.query | ||||
|       const redirectCallback = `${request.protocol}://${HOST}:${PORT}/users/oauth2/google/callback?redirectURI=${redirectURI}` | ||||
|       const redirectCallback = `${API_URL}/users/oauth2/google/callback?redirectURI=${redirectURI}` | ||||
|       const url = `${GOOGLE_BASE_URL}?client_id=${GOOGLE_CLIENT_ID}&redirect_uri=${redirectCallback}&response_type=code&scope=profile&access_type=online` | ||||
|       reply.statusCode = 200 | ||||
|       return url | ||||
|   | ||||
| @@ -12,7 +12,7 @@ import { | ||||
|   userPublicSchema | ||||
| } from '../../../models/User.js' | ||||
| import { sendEmail } from '../../../tools/email/sendEmail.js' | ||||
| import { HOST, PORT } from '../../../tools/configurations/index.js' | ||||
| import { API_URL } from '../../../tools/configurations/index.js' | ||||
|  | ||||
| const queryPostSignupSchema = Type.Object({ | ||||
|   redirectURI: Type.Optional(Type.String({ format: 'uri-reference' })) | ||||
| @@ -76,7 +76,7 @@ export const postSignupUser: FastifyPluginAsync = async (fastify) => { | ||||
|       await sendEmail({ | ||||
|         type: 'confirm-email', | ||||
|         email, | ||||
|         url: `${request.protocol}://${HOST}:${PORT}/users/confirm-email?temporaryToken=${temporaryToken}${redirectQuery}`, | ||||
|         url: `${API_URL}/users/confirm-email?temporaryToken=${temporaryToken}${redirectQuery}`, | ||||
|         language, | ||||
|         theme | ||||
|       }) | ||||
|   | ||||
| @@ -6,6 +6,7 @@ dotenv.config() | ||||
|  | ||||
| export const PORT = parseInt(process.env.PORT ?? '8080', 10) | ||||
| export const HOST = process.env.HOST ?? '0.0.0.0' | ||||
| export const API_URL = process.env.API_URL ?? `http://${HOST}:${PORT}` | ||||
| export const JWT_ACCESS_SECRET = | ||||
|   process.env.JWT_ACCESS_SECRET ?? 'accessTokenSecret' | ||||
| export const JWT_REFRESH_SECRET = | ||||
|   | ||||
		Reference in New Issue
	
	Block a user