Self hosted server with svelte framework with moralis v2

I setup my project with moralis and used vanila js for authentication. I used moralis v2. Now i am migrating my server to self hosted server but vanila js authentication is not working. it shows error “morlias auth failed invalid data”. Is it necessary to use moralis v1 or we can use v2 also with vanila js? and if i can use v2 then can anyone please help me with authentication code

Authentication with a parse server requires a custom function that looks like this one
https://v1docs.moralis.io/moralis-dapp/getting-started/self-hosting-moralis-server/client-connection#note-about-authentication

But can I use moralis v2 ?