How to run axios in KOA ctx, to register users? I have code but key gets exposed if I do it in the theme

beforeSSR: ({ state, libraries }) => async ({ ctx }) => {

    console.log("SSR all day long", ctx.status);


//Register user

  // Post request to create a post
  .post(`${wordPressSiteUrl}/?rest_route=/secure-Oauth/v2/users&${JWT_Key}&${AUTH_KEY_VALUE}`, formData)
  .then((res) => {

      .catch((err) => {

so how would I go about this? when click register button, it’ll take formdata and submit to ssr ctx how?

Hi @furrysmile2

Exposing API credentials in client side code can be a problem. We’re working to see what a good solution might be, though it might vary for different use cases.

You will probably need to use a proxy to pass the credentials. A quick google search turned up this video:

I haven’t watched it myself yet, but it may point you in the right direction. Let me know if it does.

Alternatively try googling for something like “hide api credentials with a proxy” and see if a solution for your use case comes up.