Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation request - SPA (ssr:false) w/ axios setup #692

Open
louisfoster opened this issue Jan 25, 2023 · 0 comments
Open

Documentation request - SPA (ssr:false) w/ axios setup #692

louisfoster opened this issue Jan 25, 2023 · 0 comments

Comments

@louisfoster
Copy link

Environment

------------------------------
- Operating System: `Linux`
- Node Version:     `v14.19.0`
- Nuxt Version:     `2.16.0-27720022.54e852f`
- Nitro Version:    `0.5.4`
- Package Manager:  `yarn@1.22.19`
- Builder:          `webpack`
- User Config:      `env`, `bridge`, `ssr`, `srcDir`, `modern`, `build`, `vuetify`, `buildModules`, `head`, `plugins`, `loading`, `css`, `router`, `modules`, `axios`, `typescript`, `styleResources`, `serverHandlers`, `devServerHandlers`
- Runtime Modules:  `@pinia/nuxt@0.4.6`, `@nuxtjs/axios@5.13.6`
- Build Modules:    `()`, `@nuxtjs/style-resources@1.2.1`, `@nuxt/bridge@3.0.0-27747000.69db93e`
------------------------------

Reproduction

Migrating a Nuxt 2 project w/ ssr: false. Uses axios to communicate directly with an API hosted on a subdomain to the nuxt app. Set up nuxt bridge, with nitro:

  nitro: {
    preset: 'service-worker',
    output: {
      dir: '~~/dist',
      publicDir: '~~/dist',
      serverDir: '~~/dist'
    }
  },

Deploying with netlify.

Describe the bug

I believe this isn't a bug, just a lack of clear documentation on the subject. As I'm not using a nitro function in netlify, just deploying it as a service worker, it's unclear how requests to external resources like an API now work. What I'm seeing is every request goes through the service worker, and returns the base index.html of the app. What I expect is the request to go to whatever endpoint is being requested, although I'm not seeing how to achieve this in the docs anywhere.
I think it's a fairly common setup with nuxt 2 to build an SPA with axios in this way, so my request is to provide some documentation on how to migrate to or workaround whatever is happening with nitro's service worker, as I'm finding the mental model for this confusing compared to what I got used to.

Additional context

No response

Logs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant