DEV Community

Discussion on: Handling sensitive client-side API keys in Next.js

Collapse
lyrod profile image
Lyrod

However, if you do not add "/" at the begining, the browser will fetch for "currentPath/yourUrl". So if you host the page on /random-route, it will fetch /random-route/api/hello

You need this /

Thread Thread
codegino profile image
Carlo Gino Catapang Author

Not sure what you mean by that. But it's working for me even if I start it with api or /api.

Thread Thread
lyrod profile image
Lyrod

Because you're fetching from index.js right?

Thread Thread
codegino profile image
Carlo Gino Catapang Author

Yep. Will update code to be resilient to change. Thanks.