Last active
September 1, 2022 23:41
-
-
Save felipeelia/3821646676923a46c6eb68c65a4dd750 to your computer and use it in GitHub Desktop.
WordPress MU Plugin to have it working with ngrok.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Place this file in the wp-content/mu-plugins directory and run ngrok with | |
* `ngrok http http://<local_url> --host-header=<local_url>` | |
*/ | |
$ngrok_url = '<id>.ngrok.io'; | |
define( 'WP_HOME', 'http://' . $ngrok_url ); | |
define( 'WP_SITEURL', 'http://' . $ngrok_url ); | |
function callback( $buffer ) { | |
global $ngrok_url; | |
$buffer = str_replace( '<your_local_url>', $ngrok_url, $buffer ); | |
return $buffer; | |
} | |
function buffer_start() { | |
ob_start( 'callback' ); | |
} | |
function buffer_end() { | |
ob_end_flush(); | |
} | |
add_action( 'wp_loaded', 'buffer_start' ); | |
add_action( 'shutdown', 'buffer_end' ); |
I've updated the --host-header parameter in the example @dinhtungdu, thank you very much! Do you mind explaining a bit further why that line was needed for ClassifAI? Just so we can add a comment for people with similar problems.
Do you mind explaining a bit further why that line was needed for ClassifAI?
@felipeelia For ClassifAI, we need to proxy the image file URL because it's required by Computer Vision (which we use to process the images). We don't send the image file but the absolute URL to the API.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For ClassifAI, we will need this line to proxy the image URLs that sent to Computer Vision