Skip to content

Commit

Permalink
feat: switch gateway host per deployment (storacha#427)
Browse files Browse the repository at this point in the history
Switches the gateway host based on env var `VITE_W3UP_GATEWAY_HOST`.

Co-authored-by: Travis Vachon <[email protected]>
  • Loading branch information
Alan Shaw and travis authored Mar 23, 2023
1 parent 786b969 commit 9a9c7da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
env:
VITE_W3UP_PROVIDER: did:web:nft.storage
VITE_W3UP_SERVICE_BRAND_NAME: 'NFT.Storage'
VITE_W3UP_GATEWAY_HOST: nftstorage.link
- name: Publish console.nft.storage
uses: ./.github/actions/preview
with:
Expand Down
3 changes: 2 additions & 1 deletion examples/react/w3console/src/components/Uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Uploader as UploaderCore,
useUploaderComponent
} from '@w3ui/react-uploader'
import { gatewayHost } from '../components/services'

export const Uploading = ({
file,
Expand Down Expand Up @@ -49,7 +50,7 @@ export const Done = ({ dataCID }: DoneProps): JSX.Element => {
<h1 className='font-bold text-sm uppercase text-gray-400 mb-1'>Uploaded</h1>
<a
className='font-mono text-xs'
href={`https://${cid}.ipfs.w3s.link/`}
href={`https://${cid}.ipfs.${gatewayHost}/`}
>
{cid}
</a>
Expand Down
3 changes: 2 additions & 1 deletion examples/react/w3console/src/components/UploadsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { ChevronLeftIcon, ChevronRightIcon, ArrowPathIcon } from '@heroicons/react/20/solid'
import type { UploadListResult } from '@w3ui/uploads-list-core'
import { UploadsList as UploadsListCore } from '@w3ui/react-uploads-list'
import { gatewayHost } from '../components/services'

interface UploadsProps {
uploads?: UploadListResult[]
Expand Down Expand Up @@ -33,7 +34,7 @@ function Uploads ({ uploads, loading }: UploadsProps): JSX.Element {
{uploads.map(({ root }) => (
<tr key={root.toString()}>
<td className="w-64 p-2 pl-3 font-mono text-sm">
<a href={`https://${root.toString()}.ipfs.w3s.link/`}>
<a href={`https://${root.toString()}.ipfs.${gatewayHost}/`}>
{root.toString()}
</a>
</td>
Expand Down
2 changes: 2 additions & 0 deletions examples/react/w3console/src/components/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ export const uploadServiceConnection = connect<Service>({
method: 'POST',
}),
})

export const gatewayHost = import.meta.env.VITE_W3UP_GATEWAY_HOST ?? 'w3s.link'

0 comments on commit 9a9c7da

Please sign in to comment.