# Next.js Setting up Authentication

**URL:** <https://forum.flow.com/t/next-js-setting-up-authentication/1666>\
**Category:** Flow JavaScript SDK\
**Tags:** flow-sdk-js\
**Created:** [April 7, 2021, 3:36pm UTC](https://forum.flow.com/t/next-js-setting-up-authentication/1666 "2021-04-07T15:36:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phenomenon](https://avatars.discourse-cdn.com/v4/letter/p/9fc348/32.png) [@Phenomenon](https://forum.flow.com/u/Phenomenon)\
**Post date:** [April 7, 2021, 3:36pm UTC](https://forum.flow.com/t/next-js-setting-up-authentication/1666/1 "2021-04-07T15:36:04Z")

</div>

Hello,

I’m trying to set up the Authentication in the Flow-Quick Start tutorial however, whenever I click the sign-up or log in buttons I receive an error `TypeError: Failed to construct 'URL': Invalid URL` I have a next.config.cjs and .env.local file in my root directory with the same snippets from the tutorial. Any idea what i’m missing? Thanks

---

<div class="post-metadata">

**Author:** ![Phenomenon](https://avatars.discourse-cdn.com/v4/letter/p/9fc348/32.png) [@Phenomenon](https://forum.flow.com/u/Phenomenon)\
**Post date:** [April 8, 2021, 4:52pm UTC](https://forum.flow.com/t/next-js-setting-up-authentication/1666/2 "2021-04-08T16:52:02Z")

</div>

I create a public repo on github incase someone would like more information. Appreciate any help! Thanks [GitHub - IbrahimSam96/Collect: Flow BlockChain Quick Start Tutorial](https://github.com/IbrahimSam96/Collect)

---

<div class="post-metadata">

**Author:** ![Kartik](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@Kartik](https://forum.flow.com/u/Kartik)\
**Post date:** [June 15, 2021, 4:47am UTC](https://forum.flow.com/t/next-js-setting-up-authentication/1666/3 "2021-06-15T04:47:02Z")

</div>

Hi @Phenomenon , I was also facing the same issue. I was able to resolve it. Just check that your config file is inside the ‘src’ of your frontend app and the .env file outside the ‘src’ folder. This worked for me. Hope it helps!

Thanks!

---

<div class="post-metadata">

**Author:** ![Marco](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@Marco](https://forum.flow.com/u/Marco)\
**Post date:** [July 8, 2021, 11:36am UTC](https://forum.flow.com/t/next-js-setting-up-authentication/1666/4 "2021-07-08T11:36:42Z")

</div>

Hi @Phenomenon, did you solve at the end? Even with the @Kartik clue, I’m still getting that issue on the standard nextjs setup. My **config.js** is on the **/src** folder while **.env.local** in the root and **index.js** in **/pages**

---

<div class="post-metadata">

**Author:** ![Babayaga](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@Babayaga](https://forum.flow.com/u/Babayaga)\
**Post date:** [July 9, 2021, 8:09pm UTC](https://forum.flow.com/t/next-js-setting-up-authentication/1666/5 "2021-07-09T20:09:37Z")

</div>

@Phenomenon @Kartik i found the solution if you guys still need it

1. uninstall dotenv npm install dotenv
2. add NEXT\_PUBLIC\_ to each env variable.  
This should fix the problem
