Headless WordPress GraphQL endpoint results in 404 URL not found with XAMPP

Headless WordPress GraphQL endpoint results in 404 URL not found with XAMPP


1

I am trying to consume a GraphQL endpoint (autogenerated from a headless WordPress project) which is served over XAMPP Apache localhost server, but when I hit the endpoint with suggested from the GraphQL settings in WordPress (https://localhost/does-pizza/graphql) I get back a 404 URL not found.

Some details that could be useful to anybody trying to answer this question:

  • The project folder name is actually ‘does-pizza’, hence the autogenerated endpoint

Headless WordPress GraphQL endpoint results in 404 URL not found with XAMPP

  • The WordPress side of my project works just fine, in fact, I am able to send GraphQL queries through the provided Ide

Headless WordPress GraphQL endpoint results in 404 URL not found with XAMPP

  • The wp-config.php just in case you need it
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the installation.
 * You don't have to use the web site, you can copy this file to "wp-config.php"
 * and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * Database settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'does_pizza' );

/** Database username */
define( 'DB_USER', 'root' );

/** Database password */
define( 'DB_PASSWORD', '' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         '/fOC;iXzZpRnq[-,Qks$w!.rdjZO?m^A1|lI:k,}i$*.YzsJzpd)Q&S4)O0JpU^P' );
define( 'SECURE_AUTH_KEY',  '`0TnWd!<k+cCa9EIH7+P`g>BqZnyJ<NM8Z`;7u%sm%r4gQFS@%Qj53vi8n7P|):b' );
define( 'LOGGED_IN_KEY',    '05Y6C;<O%V5Ng<gP%W]vTnO2X;qc%;ncm8@,,0#Q#,UlmDl!{&yPzMa-cdh<2>I$' );
define( 'NONCE_KEY',        'Lf_NZQ,~-EI]!4KU4c682fy0xovx]r&jXG70J^-tRms(NQ=,7,rZYW8siDyVd,({' );
define( 'AUTH_SALT',        'aw!Cmo?uv>l 0Ph#{;T[)G9,XdzT+M~unG!M6A1R)}Jbu3QUC}&+~/taon{~U{9}' );
define( 'SECURE_AUTH_SALT', ')]#jI2IJZySp)b<Io~!xwY%ADUmXbbl^AH#gty({Bhjl4XsjJPw+1[?r/](6^Q8}' );
define( 'LOGGED_IN_SALT',   '}T:i=Y_9ET#(uWLLu$u?p1k{V1M7t$@0=XX}!>lIa>T.[E>$4$s6 EF#>F+L;O,S' );
define( 'NONCE_SALT',       'uf3S3C.]HaSPazeZgM^HNTLb<v63QFhT[t`W|`qZL$MdrY/$bOljiU^PaFb~=En:' );

/**#@-*/

/**
 * WordPress database table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */



/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php'; 
  • The same request in Postman

    Headless WordPress GraphQL endpoint results in 404 URL not found with XAMPP

  • In Postman I am disabling the SLL certificate, just because I want to see the request succeed, but I’d of course rather use it

  • I have tried to call both localhost on port 443 and 80 but I get the same result

This is the first time I try to do something like this, so if you need any extra piece of information just let me know it.

Thanks in advance for any help 🙂

2 Answers
2


6

I have finally found the answer.

Based on the Permalink settings in WordPress, I had to change https://localhost/does-pizza/graphql to https://localhost/does-pizza/index.php?graphql


0

To add onto this top answer: same goes for using localhost/index.php?graphql endpoint instead of localhost/graphql



Leave a Reply

Your email address will not be published. Required fields are marked *