Next.js Discord

Discord Forum

navigator.clipboard is undefined in prod. build on VPS, but works on my PC tho.

So,
I just made a production build, and tested navigator.clipboard.writeText on my local PC. It worked flawlessly.
But the i pushed it to git and after updating it, npm i and npm run build on the VPS, it shows this:
1 photo (local pc, dont mind the error)
2 photo ( website hosted on vps ):

It is the same code

11 Replies

can you share the code where you're using the navigator?
Answer
Navigator clipboard only works in secure contexts, meaning in localhost and https
hmm, so it doesn't work on http (excluding localhost)
how can i setup the https on in next.js?
add ssl for your vps?
using certbot or something, but that is different discussion. Consider closing this thread
Original message was deleted
^