File size: 2,728 Bytes
bea5ece
 
09a0ca0
bea5ece
 
 
d0c651b
bea5ece
 
 
 
d0c651b
 
 
 
 
46547ea
 
 
 
 
a749a17
 
 
 
bea5ece
 
594bcb9
d0c651b
 
594bcb9
4ca811c
682be0d
4ca811c
594bcb9
 
 
d0c651b
594bcb9
 
 
2e339cc
 
d442aa9
09a0ca0
 
 
 
 
bea5ece
 
1713c96
 
bea5ece
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f55ea61
 
 
bea5ece
f55ea61
bea5ece
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
 * Custom wp-config.php for Hugging Face Spaces + Vercel Proxy + Aiven MySQL
 */

// --- PROXY AWARENESS ---
$is_branded_proxy = false;
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
    $_SERVER['HTTPS'] = 'on';
}

$forwarded_host = $_SERVER['HTTP_X_FORWARDED_HOST'] ?? '';
// Only treat as proxy if it's NOT a direct HF link
if ($forwarded_host && strpos($forwarded_host, 'hf.space') === false) {
    $is_branded_proxy = true;
    $_SERVER['HTTP_HOST'] = $forwarded_host;
    
    // Fix REQUEST_URI for WordPress when behind Vercel rewrite
    if (strpos($_SERVER['REQUEST_URI'], '/blog') !== 0) {
        $_SERVER['REQUEST_URI'] = '/blog' . $_SERVER['REQUEST_URI'];
    }

    // Fix SCRIPT_NAME and PHP_SELF for subpath proxying
    $_SERVER['SCRIPT_NAME'] = '/blog' . $_SERVER['SCRIPT_NAME'];
    $_SERVER['PHP_SELF'] = '/blog' . $_SERVER['PHP_SELF'];
}

// Ensure WordPress knows its public URL
if ($is_branded_proxy) {
    // Branded view through Vercel
    define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/blog');
    // Bypass Vercel WAF for wp-admin by pointing SITEURL directly to Hugging Face
    define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/blog');
    define('ADMIN_COOKIE_PATH', '/');
    define('COOKIEPATH', '/blog/');
    define('SITECOOKIEPATH', '/blog/');
} else {
    // Direct view on Hugging Face (or other non-branded domains)
    define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
    define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
}

define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] ?? '');

// --- AIVEN MYSQL CONFIGURATION ---
define('DB_NAME', 'defaultdb');
define('DB_USER', 'avnadmin');
define('DB_PASSWORD', 'AVNS_5wu7NICxxCSSiTuBqcP');
define('DB_HOST', 'aureliansystems-eyuan151-c338.b.aivencloud.com:24495');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
// Required for Aiven MySQL
define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);

// --- AUTH KEYS (GENERATED) ---
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

$table_prefix = 'wp_';

define('WP_DEBUG', false);

// Force clean permalinks for SEO behind proxy
define('GOT_REWRITE', true);

if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', __DIR__ . '/' );
}

require_once ABSPATH . 'wp-settings.php';