Skip to content

Commit

Permalink
Merge pull request #453 from reservoirprotocol/jaden/grwth-3762
Browse files Browse the repository at this point in the history
feat: proxy changes
  • Loading branch information
pedromcunha authored Jan 3, 2024
2 parents e1f0007 + f299559 commit ebb431d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 171 deletions.
2 changes: 1 addition & 1 deletion components/collections/CollectionActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const CollectionActions: FC<CollectionActionsProps> = ({ collection }) => {
}
setIsRefreshing(true)
fetcher(
`${window.location.origin}/${marketplaceChain.proxyApi}/collections/refresh/v2`,
`${process.env.NEXT_PUBLIC_PROXY_URL}${marketplaceChain.proxyApi}/collections/refresh/v2`,
undefined,
{
method: 'POST',
Expand Down
4 changes: 2 additions & 2 deletions components/collections/TokenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ export default ({
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
const url = `${proxyApi}/redirect/sources/${token?.market?.floorAsk?.source?.domain}/tokens/${token?.token?.contract}:${token?.token?.tokenId}/link/v2`
const url = `${process.env.NEXT_PUBLIC_PROXY_URL}${proxyApi}/redirect/sources/${token?.market?.floorAsk?.source?.domain}/tokens/${token?.token?.contract}:${token?.token?.tokenId}/link/v2`
window.open(url, '_blank')
}}
src={`${proxyApi}/redirect/sources/${token?.market?.floorAsk?.source?.domain}/logo/v2`}
src={`${process.env.NEXT_PUBLIC_PROXY_URL}${proxyApi}/redirect/sources/${token?.market?.floorAsk?.source?.domain}/logo/v2`}
/>
) : null}
</Flex>
Expand Down
4 changes: 2 additions & 2 deletions components/portfolio/PortfolioTokenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export default ({
height: 20,
borderRadius: '50%',
}}
src={`${proxyApi}/redirect/sources/${token?.ownership?.floorAsk?.source?.domain}/logo/v2`}
src={`${process.env.NEXT_PUBLIC_PROXY_URL}${proxyApi}/redirect/sources/${token?.ownership?.floorAsk?.source?.domain}/logo/v2`}
/>
)}
</>
Expand Down Expand Up @@ -470,7 +470,7 @@ export default ({
}
setIsRefreshing(true)
fetcher(
`${window.location.origin}/${proxyApi}/tokens/refresh/v1`,
`${process.env.NEXT_PUBLIC_PROXY_URL}${proxyApi}/tokens/refresh/v1`,
undefined,
{
method: 'POST',
Expand Down
4 changes: 2 additions & 2 deletions components/portfolio/TokenTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ const TokenTableRow: FC<TokenTableRowProps> = ({
}
setIsRefreshing(true)
fetcher(
`${window.location.origin}/${proxyApi}/tokens/refresh/v1`,
`${process.env.NEXT_PUBLIC_PROXY_URL}${proxyApi}/tokens/refresh/v1`,
undefined,
{
method: 'POST',
Expand Down Expand Up @@ -926,7 +926,7 @@ const TokenTableRow: FC<TokenTableRowProps> = ({
}
setIsRefreshing(true)
fetcher(
`${window.location.origin}/${proxyApi}/tokens/refresh/v1`,
`${process.env.NEXT_PUBLIC_PROXY_URL}${proxyApi}/tokens/refresh/v1`,
undefined,
{
method: 'POST',
Expand Down
23 changes: 13 additions & 10 deletions pages/[chain]/asset/[assetId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ const IndexPage: NextPage<Props> = ({ assetId, ssr }) => {
}
setIsRefreshing(true)
fetcher(
`${window.location.origin}/${proxyApi}/tokens/refresh/v1`,
`${process.env.NEXT_PUBLIC_PROXY_URL}${proxyApi}/tokens/refresh/v1`,
undefined,
{
method: 'POST',
Expand Down Expand Up @@ -416,8 +416,8 @@ const IndexPage: NextPage<Props> = ({ assetId, ssr }) => {
title: 'Refresh token failed',
description: ratelimit
? `This token was recently refreshed. The next available refresh is ${timeTill(
ratelimit
)}.`
ratelimit
)}.`
: `This token was recently refreshed. Please try again later.`,
})

Expand Down Expand Up @@ -453,7 +453,10 @@ const IndexPage: NextPage<Props> = ({ assetId, ssr }) => {
<Text style="subtitle3" color="subtle" css={{ mr: '$2' }}>
You own {countOwned}
</Text>
<Link href={`/portfolio/${account.address || ''}`} legacyBehavior={true}>
<Link
href={`/portfolio/${account.address || ''}`}
legacyBehavior={true}
>
<Anchor
color="primary"
weight="normal"
Expand Down Expand Up @@ -600,8 +603,8 @@ const IndexPage: NextPage<Props> = ({ assetId, ssr }) => {

type SSRProps = {
collection?:
| paths['/collections/v7']['get']['responses']['200']['schema']
| null
| paths['/collections/v7']['get']['responses']['200']['schema']
| null
tokens?: paths['/tokens/v6']['get']['responses']['200']['schema'] | null
}

Expand Down Expand Up @@ -648,10 +651,10 @@ export const getServerSideProps: GetServerSideProps<{
: {}

let collectionQuery: paths['/collections/v7']['get']['parameters']['query'] =
{
id: tokens?.tokens?.[0]?.token?.collection?.id,
normalizeRoyalties: NORMALIZE_ROYALTIES,
}
{
id: tokens?.tokens?.[0]?.token?.collection?.id,
normalizeRoyalties: NORMALIZE_ROYALTIES,
}

const collectionsPromise = fetcher(
`${reservoirBaseUrl}/collections/v7`,
Expand Down
5 changes: 2 additions & 3 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ AppWrapper.getInitialProps = async (appContext: AppContext) => {
const appProps = await NextApp.getInitialProps(appContext)
let baseUrl = ''

if (appContext.ctx.req?.headers.host) {
const host = appContext.ctx.req?.headers.host
baseUrl = `${host.includes('localhost') ? 'http' : 'https'}://${host}`
if (process.env.NEXT_PUBLIC_PROXY_URL) {
baseUrl = process.env.NEXT_PUBLIC_PROXY_URL
} else if (process.env.NEXT_PUBLIC_HOST_URL) {
baseUrl = process.env.NEXT_PUBLIC_HOST_URL || ''
}
Expand Down
151 changes: 0 additions & 151 deletions pages/api/reservoir/[...slug].ts

This file was deleted.

1 comment on commit ebb431d

@vercel
Copy link

@vercel vercel bot commented on ebb431d Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.