Skip to content

Commit

Permalink
Fix host (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
xWiiLLz authored Sep 9, 2024
1 parent 2af152a commit 2283bc6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
BASE_URL=http://localhost:3000
NEXT_PUBLIC_BASE_URL=http://localhost:3100
API_URL=http://localhost:7999

# Enable or disable authentication if disabled it will mock the user and session
Expand Down
24 changes: 16 additions & 8 deletions src/components/search-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import { SearchRequest, SearchResponse } from '@/lib/client';
import { PropsWithChildren, use, useCallback, useEffect, useMemo } from 'react';
import { Host } from '@clinia/client-common';
import client from '@clinia/client-datapartition';
import {
SearchParameters,
type SearchSDKOptions,
} from '@clinia/search-sdk-core';
import { SearchSDKProvider, useCollection } from '@clinia/search-sdk-react';
import { SearchSDKProvider } from '@clinia/search-sdk-react';
import { Collection } from '@clinia/search-sdk-react';

type SearchProviderProps = PropsWithChildren<{
Expand All @@ -17,20 +18,27 @@ type SearchProviderProps = PropsWithChildren<{
};
}>;

const getHost = (): Host => {
const url = new URL(`${process.env.NEXT_PUBLIC_BASE_URL}`);
if (url.host.endsWith('/')) {
url.host = url.host.slice(0, -1);
}

return {
protocol: url.protocol.replace(':', '') as 'http' | 'https',
url: `${url.host}/api`,
accept: 'readWrite',
};
};

const datapartitionClient = client(
'clinia',
{
mode: 'BearerToken',
bearerToken: '',
},
{
hosts: [
{
url: 'localhost:3100/api',
protocol: 'http',
accept: 'readWrite',
},
],
hosts: [getHost()],
}
);

Expand Down

0 comments on commit 2283bc6

Please sign in to comment.