@@ -5,6 +5,9 @@ import { errorLog, warnLog } from '../stdout/index.js';
55 * Validates the NEXT_PUBLIC_WORDPRESS_URL environment variable by sending a POST request to the Faust Plugin API.
66 * If the URL matches the Faust Plugin Headless URL, the validation fails, and an error is logged.
77 */
8+
9+ const FAILED_VALIDATION_MESSAGE = 'Validation Failed, Faust is shutting down:' ;
10+
811export async function validateNextWordPressUrl ( ) : Promise < void > {
912 const apiUrl = `${ getWpUrl ( ) } /wp-json/faustwp/v1/validate_public_wordpress_url` ;
1013 const headers = {
@@ -23,6 +26,13 @@ export async function validateNextWordPressUrl(): Promise<void> {
2326 } ) ;
2427
2528 if ( ! response . ok ) {
29+ errorLog (
30+ 'Validation error:' ,
31+ String ( response . status ) ,
32+ '-' ,
33+ response . statusText ,
34+ ) ;
35+
2636 if ( response . status === 404 ) {
2737 // Handle the case when the route does not exist
2838 warnLog (
@@ -31,11 +41,14 @@ export async function validateNextWordPressUrl(): Promise<void> {
3141 } else if ( response . status >= 500 && response . status < 600 ) {
3242 // Handle WordPress server error
3343 errorLog (
44+ FAILED_VALIDATION_MESSAGE ,
3445 'Could not connect to the WordPress server. Please check your WordPress URL or server status, as your site may not function correctly.' ,
3546 ) ;
47+ process . exit ( 1 ) ;
3648 } else {
3749 errorLog (
38- 'Validation Failed: Your Faust front-end site URL value is misconfigured. It should NOT match the `NEXT_PUBLIC_WORDPRESS_URL.`' ,
50+ FAILED_VALIDATION_MESSAGE ,
51+ 'Your Faust front-end site URL value is misconfigured. It should NOT match the `NEXT_PUBLIC_WORDPRESS_URL.`' ,
3952 ) ;
4053 process . exit ( 1 ) ;
4154 }
0 commit comments