fix: resolve API URL duplication, CORS issues, and image localhost URLs
- Fix duplicate /api/v1 in analytics.ts API calls - Add STRAPI_PUBLIC_URL env var for public CMS access - Update strapi.service to use public URL for images instead of localhost - Images now use https://cms.placebo.mk instead of http://localhost:1337
This commit is contained in:
1 parent
ebd1fc28d5
commit
a66db56156
3 files changed
+15
-14
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { type SharePlatform } from './social-utils';
|
||||
|
||||
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000';
|
||||
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000/api/v1';
|
||||
|
||||
export interface TrackShareParams {
|
||||
articleId: string;
|
||||
@@ -11,7 +11,7 @@ export interface TrackShareParams {
|
||||
|
||||
export const trackShare = async (params: TrackShareParams): Promise<boolean> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/analytics/share`, {
|
||||
const response = await fetch(`${API_BASE_URL}/analytics/share`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -34,8 +34,8 @@ export const trackShare = async (params: TrackShareParams): Promise<boolean> =>
|
||||
export const getShareStats = async (articleId?: string) => {
|
||||
try {
|
||||
const url = articleId
|
||||
? `${API_BASE_URL}/api/v1/analytics/shares?articleId=${articleId}`
|
||||
: `${API_BASE_URL}/api/v1/analytics/shares`;
|
||||
? `${API_BASE_URL}/analytics/shares?articleId=${articleId}`
|
||||
: `${API_BASE_URL}/analytics/shares`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
@@ -57,7 +57,7 @@ export const getShareStats = async (articleId?: string) => {
|
||||
|
||||
export const getTopSharedArticles = async (limit: number = 10) => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/analytics/shares/top?limit=${limit}`, {
|
||||
const response = await fetch(`${API_BASE_URL}/analytics/shares/top?limit=${limit}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -77,7 +77,7 @@ export const getTopSharedArticles = async (limit: number = 10) => {
|
||||
|
||||
export const getTotalShareStats = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/analytics/shares/total`, {
|
||||
const response = await fetch(`${API_BASE_URL}/analytics/shares/total`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user