yandeu / five-server-vscode

⚡ VSCode Extension for Five Server.
https://marketplace.visualstudio.com/items?itemName=yandeu.five-server
Other
121 stars 9 forks source link

Uncaught ReferenceError: SharedArrayBuffer is not defined #9

Closed lolaswift closed 3 years ago

lolaswift commented 3 years ago

Describe the bug Because these are new security requirements for using SharedArrayBuffer. Running on localhost will get the Uncaught ReferenceError: SharedArrayBuffer is not defined.

Need to set two response headers :

Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp

Have a question? Join the discussions instead.

yandeu commented 3 years ago

You can add these headers in a custom middleware:

// fiveserver.config.cjs

const customHeaders = (req, res, next) => {
  res.header('Cross-Origin-Opener-Policy', 'same-origin')
  res.header('Cross-Origin-Embedder-Policy', 'require-corp')
  next()
}

module.exports = {
  middleware: [customHeaders],
  // other settings
}

Or do you think it should be the default?

lolaswift commented 3 years ago

@yandeu You're awesome! It's working. Like this it's good enough since it's so easy to add it to any workplace. Fiveserver is the best among all similar expansions.Thank you for sharing it with the world.