nuxt-community / nuxtent-module

Seamlessly use content files in your Nuxt.js sites.
https://nuxtent-module.netlify.com/guide
MIT License
389 stars 50 forks source link

Nuxtent cannot load pages when @nuxtjs/axios is registered as a module #189

Closed brandonpittman closed 4 years ago

brandonpittman commented 5 years ago

Version

1.4.1

Reproduction link

https://github.com/brandonpittman/nuxtent-module/blob/master/examples/multiple-content-types/nuxt.config.js

Steps to reproduce

Add '@nuxtjs/axios' to nuxt.config.js

What is expected ?

Should display content files

What is actually happening?

Can't find page

This bug report is available on Nuxt community (#c142)
brandonpittman commented 5 years ago

As long as I don't include Axios in the modules list, everything works as expected.

renestalder commented 5 years ago

@brandonpittman Could you elaborate what you mean by "Nuxtent cannot load pages"? Do you have build errors? Do you have run-time errors? What are the error messages?

brandonpittman commented 5 years ago

@brandonpittman Could you elaborate what you mean by "Nuxtent cannot load pages"? Do you have build errors? Do you have run-time errors? What are the error messages?

404s.

brandonpittman commented 5 years ago

None of the examples in the repo here have @nuxtjs/axios declared as a module. If you do, you might just see what I mean. I tried it with the example repo, and it did the same thing.

renestalder commented 5 years ago

@brandonpittman Ah, okay, I see. I probably never used Axios with it.

Just out of personal curiosity, I would be interested if you have the same problems with Nuxtdown.
https://github.com/joostdecock/nuxtdown-module

Basically a fork that fixed some major issues and I used that fork for my projects as long as those major issues exist in Nuxtent.

joostdecock commented 5 years ago

This is from the top of my head, and I'm on my phone, so take it with a grain of salt:

If you're using axios in your own project, you need to be careful to keep two different instances with their own configuration. If you mix them up, nuxtent won't be able olto connect to the content-api.

A quick way to check is to open your browser development tools, and check the AJAX requests. Where are they going, and what's the response? That should guide you to where the problem lies.

joostdecock commented 5 years ago

Check the API configuration section here: https://github.com/joostdecock/nuxtdown-module/blob/master/README.md#api-configuration

brandonpittman commented 5 years ago

nuxtdown has the same problem.

Checked the AJAX requests but they're going to the same place, it seems.

renestalder commented 5 years ago

@brandonpittman Thanks for testing.

brandonpittman commented 5 years ago

So, are you guys who use Nuxtdown just pulling in Axios on a per-component basis?

joostdecock commented 5 years ago

Here's an example of a repo that uses nuxtdown and axios for other things: https://github.com/freesewing/site/blob/develop/nuxt/plugins/fs.js

ptdev commented 5 years ago

This is helpful but (imho) it's this module that should be using an isolated instance of the axios configuration instead of having it break the default axios configuration.

As it stands now, if one needs to use the official @nuxtjs/axios module for other purposes, then setting it up according to the documentation will break the content api.

I think this module should either reuse the axios configuration defined on nuxt.config.js (if available) or ideally just use a completely isolated instance where we can setup every axios parameters in the module's configuration instead of just baseURL and browserBaseURL.

This would also allow, for example, to be able to change the "content-api" prefix on this module's configuration, which currently isn't possible AFAIK (?).

cesasol commented 5 years ago

Is one of the first things I changed when starting the update, there is some progress but is slow. You can see the code on the development branch and is published here you can install it with npm i --save @dinamomx/nuxtent

brandonpittman commented 4 years ago

No one cares about this.