content icon indicating copy to clipboard operation
content copied to clipboard

Hosting on Github pages (with .nuxt.space) causes MIXED CONTENT error

Open Pentadome opened this issue 11 months ago • 1 comments

Environment

Github pages

Version

nuxt: 3.15.4 nuxt/content: 3.1.0

Reproduction

  1. Build with npx nuxi build --preset github_pages
  2. Host website on github pages.
  3. Github redirects (301) from https://x.nuxt.space/api/content/content/database.sql?v=V4I9ATcky to http://x.nuxt.space/api/content/content/database.sql/?v=V4I9ATckyK causing a MIXED CONTENT error and the browser blocking the request.

I am not sure why github pages does this.

Description

Workaround

Add the following to nuxt.config.ts

app: {
  head: {
    meta: [
      {
        "http-equiv": 'content-security-policy',
        content: 'upgrade-insecure-requests'
      }
    ]
  }
},

Additional context

No response

Logs


Pentadome avatar Feb 09 '25 14:02 Pentadome

Try adding autoSubfolderIndex: false to nitro.prerender options.

export const defineNuxtConfig({
   nitro: {
    prerender: {
      autoSubfolderIndex: false
    },
  }
})

This will prevent creating a directory for pre-rendered files, an should resolve the issue

farnabaz avatar Feb 11 '25 11:02 farnabaz