diff --git a/environments/.dev.prod-server.env b/environments/.dev.prod-server.env index 1cf7772..65016b7 100644 --- a/environments/.dev.prod-server.env +++ b/environments/.dev.prod-server.env @@ -1,3 +1 @@ - -REACT_APP_GRAPHQL_END_POINT = https://makers.bolt.fun/.netlify/functions/graphql -REACT_APP_AUTH_END_POINT = https://makers.bolt.fun/.netlify/functions/auth \ No newline at end of file +REACT_APP_API_END_POINT = https://makers.bolt.fu/.netlify/functions \ No newline at end of file diff --git a/environments/.dev.server.env b/environments/.dev.server.env index 474f506..ef196c2 100644 --- a/environments/.dev.server.env +++ b/environments/.dev.server.env @@ -1,2 +1 @@ -REACT_APP_GRAPHQL_END_POINT = http://localhost:8888/dev/graphql -REACT_APP_AUTH_END_POINT = http://localhost:8888/dev/auth \ No newline at end of file +REACT_APP_API_END_POINT = http://localhost:8888/dev \ No newline at end of file diff --git a/environments/.prod.github.env b/environments/.prod.github.env index 3b9cf33..94cbdea 100644 --- a/environments/.prod.github.env +++ b/environments/.prod.github.env @@ -1,3 +1,2 @@ REACT_APP_FOR_GITHUB=true -REACT_APP_GRAPHQL_END_POINT = https://makers.bolt.fun/.netlify/functions/graphql -REACT_APP_AUTH_END_POINT = https://makers.bolt.fun/.netlify/functions/auth \ No newline at end of file +REACT_APP_API_END_POINT = https://makers.bolt.fun/.netlify/functions \ No newline at end of file diff --git a/functions/auth/services/lnurl.service.js b/functions/auth/services/lnurl.service.js index 4eb4a1c..c78cb60 100644 --- a/functions/auth/services/lnurl.service.js +++ b/functions/auth/services/lnurl.service.js @@ -59,6 +59,7 @@ function removeExpiredHashes() { async function generateAuthUrl() { const hostname = CONSTS.LNURL_AUTH_HOST; + console.log(hostname); const secret = await generateSecret() await addHash(createHash(secret)) const url = `${hostname}?tag=login&k1=${secret}` diff --git a/functions/auth/login/index.js b/functions/login/login.js similarity index 94% rename from functions/auth/login/index.js rename to functions/login/login.js index 59462df..9d19c47 100644 --- a/functions/auth/login/index.js +++ b/functions/login/login.js @@ -1,9 +1,9 @@ -const { prisma } = require('../../prisma'); -const LnurlService = require('../services/lnurl.service') +const { prisma } = require('../prisma'); +const LnurlService = require('../auth/services/lnurl.service') const cookie = require('cookie') const jose = require('jose'); -const { CONSTS } = require('../../utils'); +const { CONSTS } = require('../utils'); async function generateAuthUrl() { diff --git a/functions/auth/logout/index.js b/functions/logout/logout.js similarity index 100% rename from functions/auth/logout/index.js rename to functions/logout/logout.js diff --git a/serverless.yml b/serverless.yml index cfd9757..a833ba1 100644 --- a/serverless.yml +++ b/serverless.yml @@ -23,24 +23,24 @@ functions: method: get cors: true login: - handler: functions/auth/login/index.handler + handler: functions/login/login.handler events: - http: - path: auth/login + path: login method: post cors: true - http: - path: auth/login + path: login method: get cors: true logout: - handler: functions/auth/logout/index.handler + handler: functions/logout/logout.handler events: - http: - path: auth/logout + path: logout method: post cors: true - http: - path: auth/logout + path: logout method: get cors: true diff --git a/src/features/Auth/pages/LoginPage/LoginPage.tsx b/src/features/Auth/pages/LoginPage/LoginPage.tsx index f190933..b54d1ee 100644 --- a/src/features/Auth/pages/LoginPage/LoginPage.tsx +++ b/src/features/Auth/pages/LoginPage/LoginPage.tsx @@ -8,7 +8,7 @@ import { useMeQuery } from "src/graphql" const getLnurlAuth = async () => { - const res = await fetch(process.env.REACT_APP_AUTH_END_POINT! + '/login') + const res = await fetch(process.env.REACT_APP_API_END_POINT! + '/login') const data = await res.json() return data; } diff --git a/src/features/Auth/pages/LogoutPage/LogoutPage.tsx b/src/features/Auth/pages/LogoutPage/LogoutPage.tsx index c8417e9..4b3286c 100644 --- a/src/features/Auth/pages/LogoutPage/LogoutPage.tsx +++ b/src/features/Auth/pages/LogoutPage/LogoutPage.tsx @@ -9,7 +9,7 @@ export default function LoginPage() { const navigate = useNavigate(); useEffect(() => { - fetch(process.env.REACT_APP_AUTH_END_POINT! + '/logout', { + fetch(process.env.REACT_APP_API_END_POINT! + '/logout', { method: "GET", 'credentials': "include" }) diff --git a/src/utils/apollo.ts b/src/utils/apollo.ts index 1fbc2ca..13c3204 100644 --- a/src/utils/apollo.ts +++ b/src/utils/apollo.ts @@ -4,8 +4,8 @@ import { RetryLink } from "@apollo/client/link/retry"; let apiClientUri = '/.netlify/functions/graphql'; -if (process.env.REACT_APP_GRAPHQL_END_POINT) - apiClientUri = process.env.REACT_APP_GRAPHQL_END_POINT +if (process.env.REACT_APP_API_END_POINT) + apiClientUri = process.env.REACT_APP_API_END_POINT + '/graphql' const httpLink = new HttpLink({ uri: apiClientUri,