I have a Rails 6 application that doesn't use a regular sql-ish database, I do searches on an LDAP directory, and because of that, I don't use regular models for users, for example.
In one of my pages, I ask the user to input a person ID and then click a "Search" button, and through javascript I grab the id and pass it into the "Search" button href. As you can see here:
example.html.erb
<form class="d-flex">
<input id="input" class="form-control me-2" placeholder="Person's ID"></input>
<a id="search" class="btn btn-outline-success">Search</a>
</form>
example.js
const inputPerson = document.getElementById('input')
const searchPerson = document.getElementById('search')
searchPerson.addEventListener('click', () => {
searchPerson.setAttribute("href", `/people/${inputPerson.value}`);
})
So here comes the problem:
In my machine, running rails s and testing it, it works fine, as it redirects to localhost:3000/people/12345example
But my website runs in an url that looks like this: shared-url.com/myappname
So I expected the href on production would look like shared-url.com/myappname/people/12345example but it's actually coming up as shared-url.com/people/12345example, and of course it fails as this url does not exist at all...
I have config.relative_url_root = '/myappname' in my config/environments/production.rb, is there any other config I should have set for it to work like that? I know I could just change the javascript href, but I believe there's something I'm doing wrong.
Thanks in advance!