Skip to content

Commit

Permalink
Merge pull request #4367 from serlo/fix/share-modal-domain-getter
Browse files Browse the repository at this point in the history
fix(bildungsraum-share): domain getter
  • Loading branch information
hejtful authored Dec 19, 2024
2 parents 33ecaad + 62b8920 commit 73d8d60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions apps/web/src/components/user-tools/share/share-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { Instance } from '@/fetcher/graphql-types/operations'
import { cn } from '@/helper/cn'
import { colors } from '@/helper/colors'
import { showToastNotice } from '@/helper/show-toast-notice'
import { serloDomain } from '@/helper/urls/serlo-domain'

export interface ShareModalProps {
isOpen: boolean
Expand All @@ -39,11 +38,6 @@ interface EntryData {
onClick?: (event: MouseEvent) => void
}

const base =
process.env.NODE_ENV === 'development'
? 'http://localhost:3000'
: 'https://' + serloDomain

export function ShareModal({
isOpen,
setIsOpen,
Expand Down Expand Up @@ -82,7 +76,7 @@ export function ShareModal({
async function copyContentToClipboard() {
if (!pathOrId) return
try {
const url = `${base}/api/frontend/bildungsraum-share?href=${encodeURIComponent(pathOrId)}`
const url = `/api/frontend/bildungsraum-share?href=${encodeURIComponent(pathOrId)}`
const res = await fetch(url)
const data = (await res.json()) as string
if (!res.ok) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/api/frontend/bildungsraum-share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { gql } from 'graphql-request'
import type { NextApiRequest, NextApiResponse } from 'next'

import { endpoint } from '@/api/endpoint'
import { InjectionOnlyContentQuery } from '@/fetcher/graphql-types/operations'
import { ShareEditorContentQuery } from '@/fetcher/graphql-types/operations'
import { isProduction } from '@/helper/is-production'

/**
Expand Down Expand Up @@ -38,7 +38,7 @@ export default async function handler(
body: JSON.stringify({ query, variables: { path } }),
})
.then((res) => res.json())
.then((data: { data: InjectionOnlyContentQuery }) => {
.then((data: { data: ShareEditorContentQuery }) => {
if (!data.data?.uuid) {
return res.status(404).json('not found')
}
Expand Down

0 comments on commit 73d8d60

Please sign in to comment.