# Route resolver returns 401

**URL:** <https://community.prismic.io/t/route-resolver-returns-401/3047>\
**Category:** Developing with Prismic\
**Tags:** nuxtjs\
**Created:** [December 7, 2020, 2:47pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047 "2020-12-07T14:47:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [December 7, 2020, 2:47pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/1 "2020-12-07T14:47:41Z")

</div>

I am trying to use the new routes resolver by adding this in my `nuxt.config.js`:

```auto
prismic: {
  endpoint: process.env.PRISMIC_URL,
  apiOptions: {
    accessToken: process.env.PRISMIC_API_KEY,
    routes: [
      {
        type: 'page',
        path: '/:lang/:uid'
      }
    ]
  },
  disableGenerator: false
}

```

It doesn't seem to work well though since I keep getting error 401 (`Unexpected status code [401] on URL ...` and `Failed to init Prismic API, preventing app fatal error.`).

How do I fix this?

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [December 7, 2020, 3:05pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/2 "2020-12-07T15:05:25Z")

</div>

Hi Julian,

Since this is a 401 and is related to authorisation, I'm guessing it's because the access token field isn't defined liked it is here:

> **[Configuration](https://prismic.nuxtjs.org/configuration#apioptions)**
>
> Easily connect your Nuxt.js application to your content hosted on Prismic

It should be

```auto
access_token

```

not

```auto
accessToken

```

Though I could be wrong. So please try this out.

Thanks.

---

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [December 7, 2020, 3:09pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/4 "2020-12-07T15:09:38Z")

</div>

That was my thought as well, but I'm still getting 401

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [December 7, 2020, 3:10pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/5 "2020-12-07T15:10:12Z")

</div>

Also is this a Slicemachine project? Because you will need to have Slicemachine activated on your repo to have access to the route resolver.

---

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [December 7, 2020, 3:11pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/6 "2020-12-07T15:11:47Z")

</div>

Yes and it is activated on the repo

---

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [December 7, 2020, 3:13pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/7 "2020-12-07T15:13:54Z")

</div>

The error says `Invalid access token`, but it works when I remove the routes array.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [December 7, 2020, 3:15pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/8 "2020-12-07T15:15:19Z")

</div>

What happens if you make your repo access public?

---

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [December 7, 2020, 3:20pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/9 "2020-12-07T15:20:51Z")

</div>

Edit: It works again if I remove the routes array and change it back to `accessToken` without the `_`.

I get 400/404 when making it public, but that could just be me not setting it up properly. No 401 though.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [December 7, 2020, 3:26pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/10 "2020-12-07T15:26:39Z")

</div>

I'm not sure in that case. Are you using Graphquery anywhere in this project?

Did you define the page document like so? `~/pages/_lang/_uid.vue` like we do in the multi-language example:

> **[prismicio/nuxt-multi-language-site](https://github.com/prismicio/nuxt-multi-language-site/tree/master/pages)**
>
> A Example of how to build and mult-language website with a language switcher in Prismic and Nuxt - prismicio/nuxt-multi-language-site

You don't really need the route resolver for the above URL structure anyway. You could just use the link resolver like we do in that project.

> <https://github.com/prismicio/nuxt-multi-language-site/blob/master/app/prismic/link-resolver.js>

---

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [December 7, 2020, 3:33pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/11 "2020-12-07T15:33:17Z")

</div>

Yep, im using a copy of that project.

I do need the route resolver though, since I need to make deeper nested routes eventually.

My best guess is that the `routes` array doesn't seem happy about having siblings in the `apiOptions`. Which basically means you can't have a private repo if you want to use the slice machine.

---

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [December 7, 2020, 3:36pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/12 "2020-12-07T15:36:36Z")

</div>

> [@Phil](#):
>
> I'm not sure in that case. Are you using Graphquery anywhere in this project?

I do not use Graphquery anywhere.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [December 7, 2020, 5:19pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/13 "2020-12-07T17:19:03Z")

</div>

OK, So it seems your thought about not being able to have these 2 apiOptions at the same time is correct. I talked with the team and it's an issue in that we don't pass the parameters correctly in the prismic-javacript library so it causes this error.

I've talked with the team and apparently they have been working on a fix for this already. We are going to discuss this further tomorrow as to how we can get the fix out there.

It won't be available right away, so for now you won't be able to have a private repo with the routes features. If/when I have any update on this I'll let you know here.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [December 14, 2020, 12:24pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/14 "2020-12-14T12:24:09Z")

</div>

The fix for this is being reviewed and tested. Once it's shipped we'll update you here.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 9, 2021, 9:53am UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/16 "2021-04-09T09:53:49Z")

</div>

Hey @juliandreas,

The fix was published for this a long time ago apparently, are your dependencies up to date?

My bad on the communication.

This fix is here:

> <https://github.com/prismicio/prismic-javascript/blob/22b071907acc365e4558a3db928fa2de35a3f89d/src/Api.ts#L29>

Maybe the nuxt kit isn't using this version. I'm confirming with the team.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 9, 2021, 9:57am UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/17 "2021-04-09T09:57:06Z")

</div>

The nuxt kit should be using the apparently, trying update you nuxt/prismic module.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 9, 2021, 9:57am UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/18 "2021-04-09T09:57:17Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [April 19, 2021, 4:10pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/19 "2021-04-19T16:10:49Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 23, 2021, 4:52pm UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/20 "2021-04-23T16:52:12Z")

</div>



---

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [April 23, 2021, 10:42am UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/22 "2021-04-23T10:42:30Z")

</div>

Hello Phil,

I saw your answer now and I havn't had time to try this out before now.

It's still not working for me. As soon as I make the repo private I get 401.

![65ba267eff713790754c609130473a42ab167275](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/3/38ef3e2c546f43c47443ff5d355ae1ea61b22eb8.jpeg)

These are my dependencies:

```
"dependencies": {
    "@nuxtjs/axios": "^5.13.1",
    "@nuxtjs/prismic": "^1.2.6",
    "@prismicio/client": "^4.0.0",
    "@prismicio/vue": "^2.0.11",
    "cookies": "^0.8.0",
    "nuxt": "^2.15.3",
    "prismic-dom": "^2.2.4"
  },
  "devDependencies": {
    "@nuxt/postcss8": "^1.1.3",
    "@nuxtjs/dotenv": "^1.4.1",
    "@nuxtjs/eslint-config": "^6.0.0",
    "@nuxtjs/eslint-module": "^3.0.2",
    "@nuxtjs/svg": "^0.1.12",
    "@nuxtjs/tailwindcss": "^4.0.1",
    "babel-eslint": "^10.1.0",
    "cross-env": "^7.0.3",
    "css-loader": "^5.0.0",
    "eslint": "^7.20.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-nuxt": "^2.0.0",
    "eslint-plugin-prettier": "^3.3.1",
    "node-sass": "^5.0.0",
    "nodemon": "^2.0.7",
    "postcss": "^8.1.10",
    "postcss-import": "^13.0.0",
    "postcss-loader": "^4.1.0",
    "postcss-url": "^10.1.1",
    "sass-loader": "^10.1.1"
  }

```

This is in my `nuxt.config.js`:

```
prismic: {
    endpoint: process.env.PRISMIC_URL,
    apiOptions: {
      accessToken: process.env.PRISMIC_API_KEY
    },
    disableGenerator: true
  },

```

Inside the `.env`-file I have the API-key `PRISMIC_API_KEY=EXAMPLE`. Everything else inside the `.env` works fine.

Are you guys sure it's really working for Nuxt?

---

<div class="post-metadata">

**Author:** ![juliandreas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/juliandreas/32/498_2.png) [@juliandreas](https://community.prismic.io/u/juliandreas)\
**Post date:** [April 23, 2021, 10:46am UTC](https://community.prismic.io/t/route-resolver-returns-401/3047/23 "2021-04-23T10:46:10Z")

</div>

I havn't yet tried the `accessToken` together with `routes`, which was the original problem.

[Next page](https://community.prismic.io/t/route-resolver-returns-401/3047.md?page=2)
