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