Changing '?frontity_name=' to '?translate='

On line 22 in node_modules/@frontity/core/src/server/middlewares/settings-and-store.ts

Im able to change
const nameOption = ctx.query.frontity_name;
To
const nameOption = ctx.query.translate;

This allows me to implement my language switcher and switch Frontity’s settings with the URL argument localhost:3000?translate=en

Is there any way I can have these changes persist? as any changes made to node_moduels will be lost when I clone my repo and deploy it elsewhere.

That is probably not a good idea to do, since a lot of things depend on that key/value…

You should be able to pass custom parameters to the API:

// part of frontity.settings.js
module.exports = {
  packages: [
    {
      name: "@frontity/wp-source",
      state: {
        source: {
          api: "https://site.com/wp-json",
          params: {
            translate: "en",  // <--
          },
        },
      },
    },
  ],
};

If I’m correct the params array will be added to all requests made to the API.

Thanks for the response.

Just to clarify what I’m trying to achieve. I have two sites, one for each language one with the name en and the other cy.

here is a section of my settings that uses the lang param to only get English content.

name: '@frontity/wp-source',
state: {
  source: {
    api: 'https://myWpSite/subDirectory/wp-json',
    params: {
      lang: 'en'
    },
    subdirectory: 'subDirectory'
  }
}

My problem is that on the deployed version of my site the match property for my settings isn’t working so to be able to change settings to implement the translations I need to use this ?frontity_name= argument. I just wondered if it was possible to change frontity_name so it looks better in the URL.

If it’s not possible any ideas why the match property isn’t switching my settings on my deployed site? (its working fine on localhost)

    name: 'en',
    match: [
      '.*https:\\/\\/myDeployedSite\\/subDirectory(\\/.*)?$',
      '.*http:\\/\\/localhost:3000\\/subDirectory(\\/.*)?$'
    ],
    name: 'cy',
    match: [
      '.*https:\\/\\/myDeployedSite\\/subDirectory\\/cy(\\/.*)?$',
      '.*http:\\/\\/localhost:3000\\/subDirectory\\/cy(\\/.*)?$'
    ],
export default [
{
   // default, will be used if no other site matches
   name: 'mysite-en',
   state: { ... },
   packages: [ ... ]
},
{
   // different language path
   name: 'mysite-cy',
   match: ['/cy'],
   state: { ... },
   packages: [ ... ]
}
];

Alternatively it could be that your regex isn’t correct…
This is the one I use and works without a problem.

match: ["https:\/\/example.com\/nl(\/.*)?$"],