Skip to content

Commit

Permalink
fix: setup vercel api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Feb 13, 2025
1 parent fad9bcb commit e5ffa3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import openBrowser from 'open'
import pc from 'picocolors'
import mri from 'mri'

const { white, black } = pc

import {
vercelUrl,
getSlugAndSection,
getLatestDeployment,
getProductionDeployment
} from '../src/index.js'

const { white, black } = pc

async function main () {
const { _: args, visit, ...flags } = mri(process.argv.slice(2))
const { org, project, section } = await getSlugAndSection({ args })
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import path from 'path'
import { ErrorLinkProject } from './error.js'
import { createCache } from './cache.js'

const { VERCEL_API = 'https://api.vercel.com/' } = process.env

const cache = createCache()

const vercelApi = (pathname: string) =>
fetch(`${process.env.VERCEL_API}/${pathname}`, {
fetch(new URL(pathname, VERCEL_API), {
headers: {
'Accept-Encoding': 'identity'
}
Expand Down Expand Up @@ -104,7 +106,9 @@ export async function getSlugAndSection (

if (args.length === 2) {
if (args[0] && ['current', 'latest'].includes(args[0])) {
const { id } = await (args[0] === 'current' ? getProductionDeployment() : getLatestDeployment())
const { id } = await (args[0] === 'current'
? getProductionDeployment()
: getLatestDeployment())
const { org, project } = await fromPath()

return {
Expand Down

0 comments on commit e5ffa3e

Please sign in to comment.