ALwrity + Wordpress + Wix + GSC integration

This commit is contained in:
ajaysi
2025-10-08 14:25:59 +05:30
parent 3bab3450dc
commit 5e3901c1c6
22 changed files with 2284 additions and 1222 deletions

View File

@@ -7,9 +7,17 @@ export const setAuthTokenGetter = (getter: () => Promise<string | null>) => {
authTokenGetter = getter;
};
// Create a shared axios instance for all API calls (same-origin; CRA proxy forwards to backend)
// Get API URL from environment variables
const getApiUrl = () => {
if (process.env.NODE_ENV === 'production') {
return process.env.REACT_APP_API_URL || 'https://your-backend-url.railway.app';
}
return ''; // Use proxy in development
};
// Create a shared axios instance for all API calls
export const apiClient = axios.create({
baseURL: '',
baseURL: getApiUrl(),
timeout: 60000, // Increased to 60 seconds for regular API calls
headers: {
'Content-Type': 'application/json',
@@ -18,7 +26,7 @@ export const apiClient = axios.create({
// Create a specialized client for AI operations with extended timeout
export const aiApiClient = axios.create({
baseURL: '',
baseURL: getApiUrl(),
timeout: 180000, // 3 minutes timeout for AI operations (matching 20-25 second responses)
headers: {
'Content-Type': 'application/json',
@@ -27,7 +35,7 @@ export const aiApiClient = axios.create({
// Create a specialized client for long-running operations like SEO analysis
export const longRunningApiClient = axios.create({
baseURL: '',
baseURL: getApiUrl(),
timeout: 300000, // 5 minutes timeout for SEO analysis
headers: {
'Content-Type': 'application/json',
@@ -36,7 +44,7 @@ export const longRunningApiClient = axios.create({
// Create a specialized client for polling operations with reasonable timeout
export const pollingApiClient = axios.create({
baseURL: '',
baseURL: getApiUrl(),
timeout: 60000, // 60 seconds timeout for polling status checks
headers: {
'Content-Type': 'application/json',

View File

@@ -42,53 +42,18 @@ export const useWixConnection = () => {
if (connectedFlag && tokensRaw) {
const tokens = JSON.parse(tokensRaw);
// Try to get actual site information from Wix API
try {
const { createClient, OAuthStrategy } = await import('@wix/sdk');
const wixClient = createClient({
auth: OAuthStrategy({ clientId: '75d88e36-1c76-4009-b769-15f4654556df' })
});
wixClient.auth.setTokens(tokens);
// Get member info to extract site URL
const memberInfo = await wixClient.auth.getMemberInfo();
console.log('Wix member info:', memberInfo);
// Try to extract site URL from member info or use a default
let siteUrl = 'Connected Wix Site';
if (memberInfo?.member?.email) {
// Extract domain from email or use email as identifier
const email = memberInfo.member.email;
const domain = email.split('@')[1];
siteUrl = `https://${domain}`;
}
setStatus({
connected: true,
sites: [{
id: 'wix-site-1',
blog_url: siteUrl,
blog_id: 'wix-blog',
created_at: new Date().toISOString(),
scope: 'BLOG.CREATE-DRAFT,BLOG.PUBLISH,MEDIA.MANAGE'
}],
total_sites: 1
});
} catch (apiError) {
console.log('Wix API error, using fallback:', apiError);
// Fallback if API call fails
setStatus({
connected: true,
sites: [{
id: 'wix-site-1',
blog_url: 'Connected Wix Site',
blog_id: 'wix-blog',
created_at: new Date().toISOString(),
scope: 'BLOG.CREATE-DRAFT,BLOG.PUBLISH,MEDIA.MANAGE'
}],
total_sites: 1
});
}
// Set connected status with site information from tokens
setStatus({
connected: true,
sites: [{
id: 'wix-site-1',
blog_url: 'Connected Wix Site',
blog_id: 'wix-blog',
created_at: new Date().toISOString(),
scope: 'BLOG.CREATE-DRAFT,BLOG.PUBLISH,MEDIA.MANAGE'
}],
total_sites: 1
});
console.log('Wix status checked: connected via sessionStorage');
} else {