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

[Bug?]: Cloudflare Pages + Solid AuthJS build failure #1079

Closed
2 tasks done
austin-raey opened this issue Oct 5, 2023 · 4 comments
Closed
2 tasks done

[Bug?]: Cloudflare Pages + Solid AuthJS build failure #1079

austin-raey opened this issue Oct 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@austin-raey
Copy link

austin-raey commented Oct 5, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When using the solid-start-cloudflare-pages in combination with @solid-auth/base or @solid-mediakit/auth, and deploying to Cloudflare Pages, the build will fail with the following error:

✨ Upload complete!
Success: Assets published!
Error: Failed to publish your Function. Got error: Uncaught ReferenceError: process is not defined   at functionsWorker-0.6340363868935264.js:8850:17

Expected behavior 🤔

Functions would successfully publish without a process undefined error.

Steps to reproduce 🕹

Steps:

  1. pnpm create solid choosing "with auth-js"
  2. Manually add solid-start-cloudflare-pages using the steps outlined here
    a. i.e. pnpm install solid-start-cloudflare pages, add plugins: [solid({ adapter: cloudflare({}) })] to vite.config.js.
  3. Go to CloudFlare, link the repo with the project produced by these steps and let it build. Ensure you choose dist/public as the build output directory.
  4. You will receive the process is not defined error.

Optionally after step 2, you may also replace @solid-js/auth with @solid-mediakit/auth and make relevant code updates to the generated project, noted here. Being that @solid-js/auth points to the other package, I assume @solid-mediakit/auth is the maintained version going forward.

This repo has everything configured with @solid-mediakit/auth.

Further, note that somewhere in the generated [[path]].js the following code:

function SolidAuth(config) {
    const { prefix = '/api/auth', ...authOptions } = config;
    authOptions.secret ??= process.env.AUTH_SECRET;
    authOptions.trustHost ??= !!(process.env.AUTH_TRUST_HOST ??
    ...
    
const authOpts = {
  providers: [
    GitHub({
      clientId: process.env.GITHUB_ID,
      clientSecret: process.env.GITHUB_SECRET
      ...

Context 🔦

I was testing the waters with a few frameworks (Qwik, SvelteKit, SolidStart) for a particular stack combination I'm looking for:

  • Some full-stack framework of those 3,
  • Auth.js,
  • Cloudflare Pages

SvelteKit and Qwik are able to deploy successfully to CloudFlare, however, solid's authjs package seems to exclusively use process to grab a few environment variables.

It seems to me this would need to be updated to safely check if process exists, and then probably use some Cloudflare specific global-type thing instead.

I'd love to open a PR / look into this for you guys, although I'm not sure where @solid-mediakit/auth is hosted. It would be awesome to open the door to another JAMStack provider like Cloudflare! solid-start also is one of the few out there that properly allow to do local development via Miniflare so you can actually have access to Cloudflare Bindings without needing to build / preview.

Your environment 🌎

`pnpm` 8, `node` 18, Cloudflare Pages
@austin-raey austin-raey added the bug Something isn't working label Oct 5, 2023
@austin-raey austin-raey changed the title [Bug?]: [Bug?]: Cloudflare Pages + AuthJS build failure Oct 5, 2023
@austin-raey austin-raey changed the title [Bug?]: Cloudflare Pages + AuthJS build failure [Bug?]: Cloudflare Pages + Solid AuthJS build failure Oct 5, 2023
@stickyburn
Copy link
Contributor

Is the project using SSR?

@austin-raey
Copy link
Author

@stickyburn Apologies for the very late response,

Yes, I believe this is configured to use SSR in this example. Since the { ssr } option is not configured, I believe this means it defaults to true as noted here: https://start.solidjs.com/api/vite. 😄

@stickyburn
Copy link
Contributor

Interesting. I asked because the same issue happens with client side rendering.

@ryansolid
Copy link
Member

In setting up for SolidStart's next Beta Phase built on Nitro and Vinxi we are closing all PRs/Issues that will not be merged due to the system changing. If you feel your issue was closed by mistake. Feel free to re-open it after updating/testing against 0.4.x release. Thank you for your patience.

See #1139 for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants