-
Notifications
You must be signed in to change notification settings - Fork 9
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
Pyodide headers #1104
Pyodide headers #1104
Changes from all commits
a28999d
75878f1
de5068d
60c9c3f
a674de4
732c77e
5f2998a
28a493a
9dba0f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,11 @@ const Dotenv = require("dotenv-webpack"); | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | ||
const WorkerPlugin = require("worker-plugin"); | ||
|
||
let publicUrl = process.env.PUBLIC_URL || "/"; | ||
if (!publicUrl.endsWith("/")) { | ||
publicUrl += "/"; | ||
} | ||
|
||
module.exports = { | ||
entry: { | ||
"web-component": path.resolve(__dirname, "./src/web-component.js"), | ||
|
@@ -73,6 +78,8 @@ module.exports = { | |
output: { | ||
path: path.resolve(__dirname, "./build"), | ||
filename: "[name].js", | ||
publicPath: publicUrl, | ||
workerPublicPath: publicUrl, | ||
}, | ||
devServer: { | ||
host: "0.0.0.0", | ||
|
@@ -88,6 +95,25 @@ module.exports = { | |
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS", | ||
"Access-Control-Allow-Headers": | ||
"X-Requested-With, content-type, Authorization", | ||
// Pyodide - required for input and code interruption - needed on the host app | ||
"Cross-Origin-Opener-Policy": "same-origin", | ||
"Cross-Origin-Embedder-Policy": "require-corp", | ||
Comment on lines
+98
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So are we just assuming that host pages will have to add these themselves for now, or am I not understanding? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea that's right. So on editor.raspberrypi.org we've already got these set 👍 |
||
}, | ||
setupMiddlewares: (middlewares, devServer) => { | ||
devServer.app.use((req, res, next) => { | ||
// PyodideWorker scripts - cross origin required on scripts needed for importScripts | ||
if ( | ||
[ | ||
"/pyodide/shims/_internal_sense_hat.js", | ||
"/pyodide/shims/pygal.js", | ||
"/PyodideWorker.js", | ||
].includes(req.url) | ||
) { | ||
res.setHeader("Cross-Origin-Resource-Policy", "cross-origin"); | ||
} | ||
next(); | ||
}); | ||
return middlewares; | ||
}, | ||
}, | ||
plugins: [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this one
ASSETS_URL
when the ones above arePUBLIC_URL
? I've gotten a bit confused about what the difference is between the two vars to be honest with youThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah they can both probably be merged into one env var now. When the site was deployed and assets were in the bucket but on the same domain it was causing a problem so I exposed the bucket via a URL and hit that directly a while back. But now its all bucket based
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing them all to
ASSETS_URL
in this file then we can remove that later if we want to 👍