Skip to content

Commit 183ee19

Browse files
fix(router): make exception page render in sandboxed/insecure environments (#2200)
Co-authored-by: Enzo Innocenzi <enzo@innocenzi.dev>
1 parent d7a9671 commit 183ee19

3 files changed

Lines changed: 49 additions & 41 deletions

File tree

packages/router/src/Exceptions/local/dist/main.js

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/router/src/Exceptions/local/src/entrypoint/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import ui from '@nuxt/ui/vue-plugin'
22
import { createApp } from 'vue'
3-
import { createRouter, createWebHistory } from 'vue-router'
3+
import { createMemoryHistory, createRouter } from 'vue-router'
44
import renderer from '../renderer.vue'
55
import { initializeExceptionStore } from '../store'
66
import './style.css'
77

88
const app = createApp(renderer)
99
const router = createRouter({
1010
routes: [],
11-
history: createWebHistory(),
11+
history: createMemoryHistory(),
1212
})
1313

1414
const element = document.getElementById('tempest-hydration')

packages/router/src/Exceptions/local/src/settings/settings.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useLocalStorage } from '@vueuse/core'
1+
import { useOverlay, useToast } from '@nuxt/ui/composables'
2+
import { useStorage } from '@vueuse/core'
23
import { type } from 'arktype'
34
import Dialog from './dialog.vue'
4-
import { useOverlay, useToast } from '@nuxt/ui/composables';
55

66
const overlay = useOverlay()
77

@@ -15,7 +15,15 @@ export const schema = type({
1515
export type Editor = typeof schema.infer['editor']
1616
export type Settings = typeof schema.inferIn
1717

18-
export const settings = useLocalStorage<Settings>('tempest:exceptions:settings', {})
18+
const tryGetLocalStorage = () => {
19+
try {
20+
return window.localStorage
21+
} catch {
22+
return
23+
}
24+
}
25+
26+
export const settings = useStorage<Settings>('tempest:exceptions:settings', {}, tryGetLocalStorage())
1927

2028
export async function openFileInEditor(file: string, line?: number) {
2129
if (!settings.value.editor) {

0 commit comments

Comments
 (0)