mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(vite): nuxi dev --https
working out of the box (#7547)
This commit is contained in:
parent
d882d36805
commit
9426b54562
@ -25,3 +25,7 @@ This command sets `process.env.NODE_ENV` to `development`.
|
||||
::alert{type="info"}
|
||||
If you are using a self-signed certificate in development, you will need to set `NODE_TLS_REJECT_UNAUTHORIZED=0` in your environment.
|
||||
::
|
||||
|
||||
::stabilityEdge{title="Improved HTTPS Support"}
|
||||
With next releases, `NODE_TLS_REJECT_UNAUTHORIZED` is no longer required. You can try this on edge channel using `npx nuxi-edge@latest dev --https`
|
||||
::
|
||||
|
@ -1,6 +1,3 @@
|
||||
import { $fetch } from 'ohmyfetch'
|
||||
import { getViteNodeOptions } from './vite-node-shared.mjs'
|
||||
import { viteNodeFetch } from './vite-node-shared.mjs'
|
||||
|
||||
const viteNodeOptions = getViteNodeOptions()
|
||||
|
||||
export default () => $fetch('/manifest', { baseURL: viteNodeOptions.baseURL })
|
||||
export default () => viteNodeFetch('/manifest')
|
||||
|
@ -1,3 +1,11 @@
|
||||
export function getViteNodeOptions () {
|
||||
return JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS || '{}')
|
||||
}
|
||||
import { Agent as HTTPSAgent } from 'node:https'
|
||||
import { $fetch } from 'ohmyfetch'
|
||||
|
||||
export const viteNodeOptions = JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS || '{}')
|
||||
|
||||
export const viteNodeFetch = $fetch.create({
|
||||
baseURL: viteNodeOptions.baseURL,
|
||||
agent: viteNodeOptions.baseURL.startsWith('https://')
|
||||
? new HTTPSAgent({ rejectUnauthorized: false })
|
||||
: null
|
||||
})
|
||||
|
@ -1,11 +1,9 @@
|
||||
import { performance } from 'node:perf_hooks'
|
||||
import { createError } from 'h3'
|
||||
import { ViteNodeRunner } from 'vite-node/client'
|
||||
import { $fetch } from 'ohmyfetch'
|
||||
import consola from 'consola'
|
||||
import { getViteNodeOptions } from './vite-node-shared.mjs'
|
||||
import { viteNodeOptions, viteNodeFetch } from './vite-node-shared.mjs'
|
||||
|
||||
const viteNodeOptions = getViteNodeOptions()
|
||||
const runner = createRunner()
|
||||
let render
|
||||
|
||||
@ -15,9 +13,7 @@ export default async (ssrContext) => {
|
||||
process.server = true
|
||||
|
||||
// Invalidate cache for files changed since last rendering
|
||||
const invalidates = await $fetch('/invalidates', {
|
||||
baseURL: viteNodeOptions.baseURL
|
||||
})
|
||||
const invalidates = await viteNodeFetch('/invalidates')
|
||||
const updates = runner.moduleCache.invalidateDepTree(invalidates)
|
||||
|
||||
// Execute SSR bundle on demand
|
||||
@ -39,9 +35,7 @@ function createRunner () {
|
||||
async fetchModule (id) {
|
||||
// TODO: fix in vite-node
|
||||
id = id.replace(/\/\//g, '/')
|
||||
return await $fetch('/module/' + encodeURI(id), {
|
||||
baseURL: viteNodeOptions.baseURL
|
||||
}).catch((err) => {
|
||||
return await viteNodeFetch('/module/' + encodeURI(id)).catch((err) => {
|
||||
const errorData = err?.data?.data
|
||||
if (!errorData) {
|
||||
throw err
|
||||
|
Loading…
Reference in New Issue
Block a user