Posts

Support
727-724-4212
833-316-4075
team@ubeenutrition.com
833-316-4075
team@ubeenutrition.com
add_action('graphql_response_headers_to_send', function($headers) { $headers['Access-Control-Allow-Origin'] = 'https://frontend.ubeenutrition.com'; $headers['Access-Control-Allow-Headers'] = 'Content-Type'; $headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'; return $headers; }); add_filter('wp_rest_cache/allowed_endpoints', function($endpoints) { // Cache WooCommerce product endpoints if (!isset($endpoints['wc/v3'])) { $endpoints['wc/v3'] = []; } $endpoints['wc/v3'][] = 'products'; $endpoints['wc/v3'][] = 'products/categories'; $endpoints['wc/v3'][] = 'coupons'; return $endpoints; }); // Allow frontend to access REST API and GraphQL add_action('init', function() { $origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : ''; $allowed = array( 'https://frontend.ubeenutrition.com' ); if (in_array($origin, $allowed)) { header('Access-Control-Allow-Origin: ' . $origin); header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); header('Access-Control-Allow-Headers: Content-Type, Authorization'); header('Access-Control-Allow-Credentials: true'); } if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { status_header(200); exit(); } });