500 status on preview mode

Hi,

First of all, I want to thank the Frontity team, building WP websites has become a lot more enjoyable.

Iā€™m running into problems when trying to preview pages. I keep getting Internal Server Error status 500.

My environment is:
ā€¢ Frontity project is set inside a folder in the theme folder (itā€™s a monorepo).
ā€¢ Iā€™m using Apache to serve both WP and Frontity locally. .htaccess settings added to WP root folder and a simple ProxyPass / http://localhost:3000/ for serving the node server (thereā€™s also a self-signed SSL certificate set on both, so I can run things through https).
ā€¢ Frontity is being served at https://dev.prototype.com and WP at https://local.prototype.com
ā€¢ Itā€™s a recent project, so I believe all packages are running on their latest versions.
ā€¢ Frontity Embedded Mode plugin is installed and $frontity_server is set as ā€˜https://dev.prototype.comā€™.
ā€¢ ā€“public-path https://dev.chaianalytics.com/static when building frontity

Even though the embedded mode seems to be working just fine, I canā€™t get to make the pages/posts preview posts work. No matter how I set things, I keep getting:

{
status: 500,
statusText: ā€˜Internal Server Errorā€™
}

When debugging the post revision endpoint through Postman, using the same JWT sent as frontity_source_auth, thatā€™s the result I get:

{
ā€œcodeā€: ā€œinvalid_usernameā€,
ā€œmessageā€: ā€œUnknown username. Check again or try your email address.ā€,
ā€œdataā€: null
}

Apparently, at wp_authenticate_username_password at user.php file in wp-includes the value of $username is {ā€œtypā€, which leads to the error above. Curiously, the previews work if I make that function skip errors and return true, but obviously, that canā€™t go to production.

I thought it could be some issue with my WP REST API not being able to fetch revisions, but the same error doesnā€™t happen when using Basic Auth on Postman.

Any tips or suggestions are appreciated, let me know if I can provide any more details.

Thanks in advance!

@fabriziotm, welcome to the community :slight_smile:

  1. Could you please deactivate all your plugins and leave only the Embedded mode one to see if any of them are causing the problem?
  2. If you already did that and it keeps failing, please open an issue in the https://github.com/frontity/frontity-embedded-proof-of-concept repository and we will take a look at it.

By the way, I bet you can use http://localhost:3000 in your $frontity_server variable if you are running both Frontity and WordPress in the same server.

Also, make sure to run Frontity using a process manager like PM2 or forever.

2 Likes

Hi Luis,

Indeed, the problem was one of the plugins I was using (WP API SwaggerUI), which is very annoying.

Thank you very much!

1 Like

Awesome, I am glad it is solved now @fabriziotm :slight_smile: