https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • s

    sovereignChai

    04/13/2022, 10:04 PM
    Here's the repo: https://github.com/Immortalin/vite-plugin-ssr-cloudflare-pages-demo
  • s

    sovereignChai

    04/13/2022, 10:05 PM
    @Isaac McFadyen | YYZ01 lemme know if you have any difficulty running it
  • i

    Isaac McFadyen | YYZ01

    04/13/2022, 10:06 PM
    I don't know that I will be able to help much... that looks like a fairly complex project (and has multiple external dependencies). You might be best trying to take away stuff until things work and go from there to figure out what's causing your error.
  • s

    sovereignChai

    04/13/2022, 10:07 PM
    Currently it works under miniflare, it is just the static assets that are not being served when deployed on cloudflare
  • s

    sovereignChai

    04/13/2022, 10:07 PM
    The webpage itself loads fine
  • s

    sovereignChai

    04/13/2022, 10:08 PM
    But for some reason this part doesn't work too well: https://github.com/Immortalin/vite-plugin-ssr-cloudflare-pages-demo/blob/be2594d5e9185f9b709db356396c4aad4586117f/worker/worker.ts#L22
  • s

    sovereignChai

    04/13/2022, 10:08 PM
    Everything works fine under miniflare though
  • i

    Isaac McFadyen | YYZ01

    04/13/2022, 10:09 PM
    Can you try returning the error instead of logging it where you can't see it?
  • s

    sovereignChai

    04/13/2022, 10:15 PM
    I replaced the error handler with: `return new Response(
    Internal Error: ${e}
    , { status: 500 });` but it doesn't seem to be working
  • s

    sovereignChai

    04/13/2022, 10:15 PM
    here's the deployment: https://62ccf01b.listhq.pages.dev/
  • s

    sovereignChai

    04/13/2022, 10:15 PM
    if you see the network logs
  • s

    sovereignChai

    04/13/2022, 10:15 PM
    the 500 errors don't return anything
  • s

    sovereignChai

    04/13/2022, 10:34 PM
    Problem fixed
  • s

    sovereignChai

    04/13/2022, 10:34 PM
    As it seems, setting headers seem to trigger an error on the cloudflare side
  • s

    sovereignChai

    04/13/2022, 10:35 PM
    I am not sure which specific security header is causing the issue as the worker cannot successfully log or even return the error as a response
  • s

    sovereignChai

    04/13/2022, 10:35 PM
    but removing the security headers code solved the problem
  • k

    kian

    04/13/2022, 10:37 PM
    Copy code
    js
      response.headers.set("X-XSS-Protection", "1; mode=block");
      response.headers.set("X-Content-Type-Options", "nosniff");
      response.headers.set("X-Frame-Options", "DENY");
      response.headers.set("Referrer-Policy", "unsafe-url");
      response.headers.set("Feature-Policy", "none");
  • k

    kian

    04/13/2022, 10:37 PM
    These?
  • s

    sovereignChai

    04/13/2022, 10:37 PM
    Yes
  • s

    sovereignChai

    04/13/2022, 10:37 PM
    I think there is a bug in miniflare
  • s

    sovereignChai

    04/13/2022, 10:37 PM
    the headers are supposed to be immutable
  • s

    sovereignChai

    04/13/2022, 10:37 PM
    according to cloudflare documentation
  • s

    sovereignChai

    04/13/2022, 10:37 PM
  • s

    sovereignChai

    04/13/2022, 10:37 PM
    miniflare isn't catching it
  • o

    oldschoolcurry

    04/13/2022, 10:37 PM
    A noob question: how can I read JSON POST variable? code: export async function onRequestPost(request) I POST: { "first_name": ":)", "email": "info@cloudflarethebomb.com", }
  • k

    kian

    04/13/2022, 10:38 PM
    they are indeed - on the original response object
  • s

    sovereignChai

    04/13/2022, 10:38 PM
    @kian are you able to replicate the problem
  • s

    sovereignChai

    04/13/2022, 10:39 PM
    Shall I file a bug report against miniflare?
  • k

    kian

    04/13/2022, 10:39 PM
    I don't use Miniflare personally but if you're able to modify the original response object then yeah, that's not in-line with how it'll work in Workers/Functions
  • s

    sovereignChai

    04/13/2022, 10:40 PM
    The issue right now is that the app works fine in miniflare but not production
1...119120121...392Latest