add base url to template

This commit is contained in:
reya 2024-01-23 13:35:28 +07:00
commit 67f43d95af
3 changed files with 4 additions and 3 deletions

View file

@ -163,6 +163,7 @@ export async function processRegistrationWebHandler(request, reply) {
try { try {
const record = await getAndValidateStateOfRequest(request); const record = await getAndValidateStateOfRequest(request);
const body = request.body; const body = request.body;
const baseUrl = new URL(request.url).pathname.split('/')[1];
// we serialize the payload again and store it // we serialize the payload again and store it
// along with the allowed flag // along with the allowed flag
@ -179,7 +180,7 @@ export async function processRegistrationWebHandler(request, reply) {
const [ username, domain, email ] = JSON.parse(record.params!); const [ username, domain, email ] = JSON.parse(record.params!);
const nip05 = `${username}@${domain}`; const nip05 = `${username}@${domain}`;
return reply.view("/templates/createAccount.handlebar", { record, email, username, domain, nip05, error: e.message}); return reply.view("/templates/createAccount.handlebar", { baseUrl, record, email, username, domain, nip05, error: e.message});
} }
await prisma.request.update({ await prisma.request.update({

View file

@ -87,7 +87,7 @@
</h1> </h1>
</div> </div>
<form <form
action="register/{{record.id}}" action="{{baseUrl}}/register/{{record.id}}"
method="POST" method="POST"
class="w-full flex flex-col gap-5"> class="w-full flex flex-col gap-5">
{{#if error}} {{#if error}}

View file

@ -52,7 +52,7 @@
</h1> </h1>
</div> </div>
<form <form
action="login" action="{{baseUrl}}/login"
method="POST" method="POST"
class="w-full flex flex-col gap-5"> class="w-full flex flex-col gap-5">