fix urls
This commit is contained in:
parent
83566f09f5
commit
96fb9eee7c
@ -27,6 +27,8 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const BACKEND_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
|
||||||
|
|
||||||
export default function TestConnectionPage() {
|
export default function TestConnectionPage() {
|
||||||
// Get getToken from useAuth hook, not from user
|
// Get getToken from useAuth hook, not from user
|
||||||
const { isSignedIn, isLoaded: isClerkLoaded, getToken } = useAuth()
|
const { isSignedIn, isLoaded: isClerkLoaded, getToken } = useAuth()
|
||||||
@ -136,7 +138,7 @@ export default function TestConnectionPage() {
|
|||||||
const checkBackendConnection = async () => {
|
const checkBackendConnection = async () => {
|
||||||
try {
|
try {
|
||||||
// Test session
|
// Test session
|
||||||
const response = await fetch('http://localhost:8000/auth/session', {
|
const response = await fetch(`${BACKEND_URL}/auth/session`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
@ -192,7 +194,7 @@ export default function TestConnectionPage() {
|
|||||||
const checkWalletConnection = async () => {
|
const checkWalletConnection = async () => {
|
||||||
if (isBackendConnected) {
|
if (isBackendConnected) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('http://localhost:8000/auth/session', {
|
const response = await fetch(`${BACKEND_URL}/auth/session`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
|
@ -6,6 +6,8 @@ import { Button } from '@workspace/ui/components/button'
|
|||||||
import { CheckBalanceWrapper } from './iframe/check-balance-iframe/CheckBalanceWrapper'
|
import { CheckBalanceWrapper } from './iframe/check-balance-iframe/CheckBalanceWrapper'
|
||||||
import { CopyIcon } from 'lucide-react'
|
import { CopyIcon } from 'lucide-react'
|
||||||
|
|
||||||
|
const BACKEND_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
|
||||||
|
|
||||||
// Generate a random nonce
|
// Generate a random nonce
|
||||||
function generateNonce() {
|
function generateNonce() {
|
||||||
return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
|
return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
|
||||||
@ -25,7 +27,7 @@ export function SIWEAuth() {
|
|||||||
const checkSession = async () => {
|
const checkSession = async () => {
|
||||||
try {
|
try {
|
||||||
setSessionStatus('checking')
|
setSessionStatus('checking')
|
||||||
const response = await fetch('http://localhost:8000/auth/session', {
|
const response = await fetch(`${BACKEND_URL}/auth/session`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
@ -171,7 +173,7 @@ Issued At: ${issuedAt}`
|
|||||||
setDebugInfo(prev => `${prev}\nRaw signature: ${signedMessage}`)
|
setDebugInfo(prev => `${prev}\nRaw signature: ${signedMessage}`)
|
||||||
|
|
||||||
// Try using the raw signature directly
|
// Try using the raw signature directly
|
||||||
const response = await fetch('http://localhost:8000/auth/validate', {
|
const response = await fetch(`${BACKEND_URL}/auth/validate`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -4,6 +4,8 @@ import { useState, useEffect } from 'react'
|
|||||||
import { Button } from '@workspace/ui/components/button'
|
import { Button } from '@workspace/ui/components/button'
|
||||||
import { Wallet } from 'ethers' // Add this to your package.json if not already there
|
import { Wallet } from 'ethers' // Add this to your package.json if not already there
|
||||||
|
|
||||||
|
const BACKEND_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
|
||||||
|
|
||||||
export function DirectKeyAuth() {
|
export function DirectKeyAuth() {
|
||||||
const [sessionStatus, setSessionStatus] = useState<'checking' | 'authenticated' | 'unauthenticated'>('checking')
|
const [sessionStatus, setSessionStatus] = useState<'checking' | 'authenticated' | 'unauthenticated'>('checking')
|
||||||
const [sessionData, setSessionData] = useState<any>(null)
|
const [sessionData, setSessionData] = useState<any>(null)
|
||||||
@ -14,7 +16,7 @@ export function DirectKeyAuth() {
|
|||||||
const checkSession = async () => {
|
const checkSession = async () => {
|
||||||
try {
|
try {
|
||||||
setSessionStatus('checking')
|
setSessionStatus('checking')
|
||||||
const response = await fetch('http://localhost:8000/auth/session', {
|
const response = await fetch(`${BACKEND_URL}/auth/session`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
@ -79,7 +81,7 @@ Issued At: ${issuedAt}`;
|
|||||||
console.log('Generated signature:', signature);
|
console.log('Generated signature:', signature);
|
||||||
|
|
||||||
// Send to backend
|
// Send to backend
|
||||||
const response = await fetch('http://localhost:8000/auth/validate', {
|
const response = await fetch(`${BACKEND_URL}/auth/validate`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useGQLClient } from '@/context'
|
import { useGQLClient } from '@/context'
|
||||||
|
|
||||||
|
const BACKEND_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
|
||||||
|
|
||||||
export function GQLTest() {
|
export function GQLTest() {
|
||||||
const [testResponse, setTestResponse] = useState<string>('Testing connection...')
|
const [testResponse, setTestResponse] = useState<string>('Testing connection...')
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
@ -11,7 +13,7 @@ export function GQLTest() {
|
|||||||
async function testGQLConnection() {
|
async function testGQLConnection() {
|
||||||
try {
|
try {
|
||||||
// Try a direct GraphQL query using fetch
|
// Try a direct GraphQL query using fetch
|
||||||
const response = await fetch('http://localhost:8000/graphql', {
|
const response = await fetch(`${BACKEND_URL}/graphql`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -50,7 +52,7 @@ export function GQLTest() {
|
|||||||
setTestResponse('Testing direct connection...')
|
setTestResponse('Testing direct connection...')
|
||||||
setError(null)
|
setError(null)
|
||||||
|
|
||||||
const response = await fetch('http://localhost:8000/auth/session', {
|
const response = await fetch(`${BACKEND_URL}/auth/session`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|||||||
const initGQLClient = async () => {
|
const initGQLClient = async () => {
|
||||||
try {
|
try {
|
||||||
const client = new GQLClient({
|
const client = new GQLClient({
|
||||||
gqlEndpoint: 'http://localhost:8000/graphql',
|
gqlEndpoint: `${process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'}/graphql`,
|
||||||
})
|
})
|
||||||
setGqlClient(client)
|
setGqlClient(client)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -11,6 +11,8 @@ import {
|
|||||||
useCallback
|
useCallback
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
|
||||||
|
const BACKEND_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface BackendContextType
|
* @interface BackendContextType
|
||||||
* @description Defines the structure of the BackendContext value.
|
* @description Defines the structure of the BackendContext value.
|
||||||
@ -45,7 +47,7 @@ export const BackendProvider: React.FC<{ children: ReactNode }> = ({
|
|||||||
// Check backend connection
|
// Check backend connection
|
||||||
const checkBackendConnection = useCallback(async (): Promise<void> => {
|
const checkBackendConnection = useCallback(async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('http://localhost:8000/auth/session', {
|
const response = await fetch(`${BACKEND_URL}/auth/session`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user