Use dev urls everywhere when configured that way

I think we were just using some constants that ended up returning bad
values for dev, it seemed to return a working shortlink when I went
through the flow.
This commit is contained in:
Adam Sunderland
2025-01-14 17:16:16 -05:00
parent df01c233e4
commit 08e714080e
2 changed files with 5 additions and 14 deletions

View File

@ -197,16 +197,8 @@ function ProjectMenuPopover({
* This override allows us to shim in an environment variable * This override allows us to shim in an environment variable
* for the prod token. * for the prod token.
*/ */
const token = DEV ? VITE_KC_PROD_TOKEN : auth.context.token const token = auth.context.token
if (DEV && !VITE_KC_PROD_TOKEN) { if (!token) {
toast.error(
'You need to set a prod token in your environment to share a file in development.',
{
duration: 5000,
}
)
return
} else if (!token) {
toast.error('You need to be signed in to share a file.', { toast.error('You need to be signed in to share a file.', {
duration: 5000, duration: 5000,
}) })

View File

@ -2,10 +2,9 @@ import { UnitLength_type } from '@kittycad/lib/dist/types/src/models'
import { import {
ASK_TO_OPEN_QUERY_PARAM, ASK_TO_OPEN_QUERY_PARAM,
CREATE_FILE_URL_PARAM, CREATE_FILE_URL_PARAM,
PROD_APP_URL,
} from './constants' } from './constants'
import { stringToBase64 } from './base64' import { stringToBase64 } from './base64'
import { DEV } from 'env' import { DEV, VITE_KC_SITE_BASE_URL, VITE_KC_API_BASE_URL } from 'env'
export interface FileLinkParams { export interface FileLinkParams {
code: string code: string
name: string name: string
@ -21,7 +20,7 @@ export interface FileLinkParams {
*/ */
export function createCreateFileUrl({ code, name, units }: FileLinkParams) { export function createCreateFileUrl({ code, name, units }: FileLinkParams) {
// Use the dev server if we are in development mode // Use the dev server if we are in development mode
let origin = DEV ? 'http://localhost:3000' : PROD_APP_URL let origin = DEV ? 'http://localhost:3000' : VITE_KC_SITE_BASE_URL
const searchParams = new URLSearchParams({ const searchParams = new URLSearchParams({
[CREATE_FILE_URL_PARAM]: String(true), [CREATE_FILE_URL_PARAM]: String(true),
name, name,
@ -48,7 +47,7 @@ export async function createShortlink(
* We don't use our `withBaseURL` function here because * We don't use our `withBaseURL` function here because
* there is no URL shortener service in the dev API. * there is no URL shortener service in the dev API.
*/ */
const response = await fetch('https://api.zoo.dev/user/shortlinks', { const response = await fetch(`${VITE_KC_API_BASE_URL}/user/shortlinks`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-type': 'application/json', 'Content-type': 'application/json',