Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: SharedArrayBuffer is not defined #111

Open
leo6liu opened this issue Aug 26, 2021 · 3 comments
Open

ReferenceError: SharedArrayBuffer is not defined #111

leo6liu opened this issue Aug 26, 2021 · 3 comments

Comments

@leo6liu
Copy link

leo6liu commented Aug 26, 2021

Visiting https://ffmpegwasm.github.io/vue-app/ and running a dev server locally both result in a "ReferenceError: SharedArrayBuffer is not defined" error.

I tested with both Firefox 91.0.2 and Chrome 92.0.4515.159.

@anasak-dev
Copy link

anasak-dev commented Sep 15, 2021

I ran into sharearraybuffer issue as well, and this seems to fix my issue
Open 'vue.config.js' file and update it as below

const path = require('path');
const express = require('express');

module.exports = {

publicPath: process.env.NODE_ENV === 'production'
? '/vue-app/'
: '/',
configureWebpack: {
devServer: {
before: app => {
app.use('/node_modules/', express.static(path.resolve(__dirname, 'node_modules')))
},
// Add Embedder Policy In order to resolve sharedarraybuffer issue

  headers: {
   
      'Cross-Origin-Embedder-Policy':'require-corp',
   'Cross-Origin-Opener-Policy':'same-origin',
    },
              // Add Embedder Policy In order to resolve sharedarraybuffer issue

}

}
};

After adding restart your app by command 'npm run serve'

Additionally try to open your app with localhost instead of any IP in url I think the localhost format is
supported in this case and example vue app works well after that.

Note: Credit to the guy who posted header values here ffmpegwasm/react-app#3

@dbussert
Copy link

this fix does not appear to work any longer

$ npm run serve

> vue-app@0.1.0 serve
> vue-cli-service serve

 INFO  Starting development server...
 ERROR  WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'headers'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions? }
   For typos: please correct them.
   For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.
     Loaders should be updated to allow passing options via loader options in module.rules.
     Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
     plugins: [
       new webpack.LoaderOptionsPlugin({
         // test: /\.xxx$/, // may apply this only for some modules
         options: {
           headers: …
         }
       })
      ]

@crunchstefan
Copy link

it should still work if you add it to the correct place:

const path = require('path');
const express = require('express');

module.exports = {
  publicPath: process.env.NODE_ENV === 'production'
    ? '/vue-app/'
    : '/',
  configureWebpack: {
    devServer: {
      before: app => {
        app.use('/node_modules/', express.static(path.resolve(__dirname, 'node_modules')))
      },
      headers: {
        'Cross-Origin-Embedder-Policy': 'require-corp',
        'Cross-Origin-Opener-Policy': 'same-origin',
      }
    }
  }

};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants