How to implement Faust.js Basic Http Authentication #1216
Replies: 7 comments 3 replies
-
Hey @midnitedev101. I'm wondering if you did run |
Beta Was this translation helpful? Give feedback.
-
Hi @theodesp, thanks for the tip. Running the command
|
Beta Was this translation helpful? Give feedback.
-
I checked the docs and I currently have WPGraphQL introspection enabled on the site. GraphQL Debug Mode was checked initially which makes it force-enabled according to the settings. I've also tried enabling it by itself, restarting the site and running the command again but I'm still getting the same results. If it helps any further, I'm using an OS X device v13.1. |
Beta Was this translation helpful? Give feedback.
-
Using http://localhost:10004/graphql?query=%7B__typename%7D url on web browser shows me these results as well as the curl command:
|
Beta Was this translation helpful? Give feedback.
-
Hey @midnitedev101 it may be worth it reaching out to GQty project maintainers is there is something wrong here outside the scope of Faust.js. |
Beta Was this translation helpful? Give feedback.
-
I tried out a solution by modifying the index.js file in the client folder without the generate command (https://stackoverflow.com/questions/75115469/how-to-implement-faust-js-basic-http-authentication/75116175#75116175). I updated the production code and so far the text, title and links within the posts page and on the home page are showing. The images are still missing though and the search form auto-complete gives an error after putting in text like below: Access to fetch at 'https://<backend_url>/graphql' from origin 'https://<frontend_url>.js.wpenginepowered.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. I did look into what is a limitation for CORS and it seems it doesn't play well with basic http authentication. Since current backend production environment requires this, then I'll just have to live with the fact that there are some assets that I won't be able to reliably integrate them on the front-end. |
Beta Was this translation helpful? Give feedback.
-
// auth.js const auth = createStore({ export default auth; |
Beta Was this translation helpful? Give feedback.
-
I'm implementing Headless Wordpress using Faust.js and ran into a problem. The current Wordpress backend requires basic http authentication, protected by base64-encoded credentials, before being able to access the backend site contents and I'm running the frontend with Faust.js. On a local environment, there is no need to implement adding the credentials to the header but on production (because the http authentication exists), I can't retrieve the post content as well as other assets such as images, etc. from the Wordpress backend.
I was doing some research into how to add the http authentication but so far I've only found limited examples of how to implement basic authentication to do this. One is with typescript (#845) but since I currently have the project on js code, it seems I would need to convert a lot of the files into typescript (maybe including the packages included in node_modules which I don't want to break if I did the conversion). I want to find a way to add this http basic authentication as part of the request header on my Faust.js frontend project without converting to js.
On the example, I've tried implementing this with the ts example, while using js code, but I'm getting all sorts of errors, when building it. Here's the code:
The errors I'm getting when building it are among the following:
How do I implement this feature properly?
Beta Was this translation helpful? Give feedback.
All reactions