Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yandeu committed May 21, 2023
1 parent d98ac07 commit b5a7e91
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,22 @@ export default class LiveServer {

// enable CORS
if (cors) {
const myModule = (await import('cors')).default
app.use(myModule({ credentials: true }))
const loadModule = () => {
return new Promise(resolve => {
import('cors')
.then(mod => {
return resolve(mod)
})
.catch(e => {
console.error('ERROR', e.message)
return resolve(undefined)
})
})
}
// const myModule = (await import('cors')).default
const myModule = (await loadModule()) as any
console.log(typeof myModule)
if (myModule) app.use(myModule.default({ credentials: true }))
// app.use(require('cors')({ credentials: true }))
}

Expand Down

0 comments on commit b5a7e91

Please sign in to comment.