index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. const fs = require("fs");
  3. const wasm = fs.readFileSync("./parsecd.wasm");
  4. const axios = require("axios");
  5. const { setupCache } = require("axios-cache-interceptor");
  6. const http = setupCache(axios);
  7. http.defaults.baseURL = "https://web.parsec.app";
  8. module.exports = async function (fastify, opts) {
  9. fastify.get("/", async function (request, reply) {
  10. // let { data: html, headers } = await http.get(`/`);
  11. // // let html = fs.readFileSync("./test.html").toString();
  12. // let append = fs.readFileSync("./keyboard.html").toString();
  13. // html = html.replace("</body>", append + "</body>");
  14. // headers['Cross-Origin-Embedder-Policy'] = 'require-corp';
  15. // reply.headers(headers);
  16. // reply.type("text/html");
  17. // return html;
  18. reply.headers({
  19. "Cross-Origin-Embedder-Policy": "require-corp",
  20. "Referrer-Policy": "no-referrer",
  21. "Content-Security-Policy": "frame-ancestors 'self'",
  22. "Cross-Origin-Opener-Policy": "same-origin",
  23. });
  24. return reply.sendFile("index.html");
  25. });
  26. fastify.get("/parsecd", async function (request, reply) {
  27. reply.type("application/wasm");
  28. reply.send(wasm);
  29. return;
  30. });
  31. };