Last updated: 2026-02-04
- Builder/target stack running on prefab-feb-2 host (current box, public IP
134.209.44.21). - Database Navigator tab in build session originally failed because
app/services/databasenamespace wasn’t autoloaded. We fixed this locally on prefab-feb-2 by:- Adding
app/servicestoautoload_pathsandeager_load_pathsinconfig/application.rb. - Creating
app/services/database.rband updatingapp/services/database/error_classes.rbto satisfy Zeitwerk naming. - Running
docker-compose run --rm builder-web bundle exec rails zeitwerk:check(passed) and restarting builder containers.
- Adding
- Chrome MCP verification still fails when pointed at prefab-feb3 because that domain resides on a different host (
159.89.44.171). Our changes only exist on prefab-feb-2.
- Builder UI (https://creator.prefab-feb-2.allspark.build) shows Database tab and lists tables successfully after fix.
- Live Preview for guestbook project still errors when fetching
guestbookEntriesGraphQL query:- Request:
POST https://prefab-feb-2.allspark.build/graphql - Response:
422 ActionController::InvalidAuthenticityTokencoming fromGraphqlController#execute. - Stack trace shows
ActionController::RequestForgeryProtectionraisingInvalidAuthenticityToken. - Request headers (from Rails exception page):
Origin: https://prefab-feb-2.allspark.buildX-CSRF-Token: CzWNBO5y...- Session
_csrf_tokenstored as_HRbwAaVh0Bav7sUKJaEG-1IFKSUC-zXq1hQbLPfwps.
- The Apollo client (frontend) includes
credentials: "same-origin"and pulls token from<meta name="csrf-token">.
- Request:
- Build session Live Preview is embedded via iframe under
creator.prefab-feb-2.allspark.build, but the guestbook app lives athttps://prefab-feb-2.allspark.build/. Cross-origin navigation likely causes Rails session mismatch:- GraphQL controller requires valid Rails session (
current_useror verified CSRF token). Non-authenticated visitors hitting guestbook site probably aren’t logged in, so session/cookie may not exist. GraphqlControllercallsbefore_action :raise_on_invalid_token; ifHTTP_AUTHORIZATIONheader present withoutcurrent_user, it returns 401. Not the case here.- Instead,
verify_authenticity_tokenfails. Could be because session cookie isn’t shared between builder (creator.) and target domain (prefab-feb-2.). CSRF tokens tied to session, so values mismatch. - Need to allow GraphQL to accept tokens from target domain even when session mismatch, probably by setting
protect_from_forgery with: :null_sessionor skipping verification for API clients.
- GraphQL controller requires valid Rails session (
-
Allow GraphQL POSTs without CSRF check
- In
GraphqlController, addprotect_from_forgery with: :null_sessionorskip_before_action :verify_authenticity_tokenso that stateless API requests succeed. Must ensure authentication handled elsewhere. - Many Rails GraphQL APIs disable CSRF because clients manage tokens differently. Since guestbook is public, null_session likely acceptable.
- In
-
Ensure Meta Tag Token Matches Session
- Confirm
csrf_meta_tagson guestbook layout emits token tied to visitor session. Already there (app/views/layouts/application.html.erb). If requests originate from same domain, should work. - However, Live Preview loads
https://prefab-feb-2.allspark.build/inside iframe but runs script from same origin, so browser should send cookies. Maybe GraphQL request originates before meta tag loads? Unlikely. - Another angle: GraphQL endpoint may be served from builder (creator) not target, but screenshot shows direct request to
prefab-feb-2.allspark.build/graphql(same origin). So maybe session isn’t established before query because we haven’t visited page? But initial GET should set session.
- Confirm
-
Double-check
config/initializers/cors.rbor host configs- If Rails sees
Originheader even on same origin? It should allow.
- If Rails sees
Given time, easiest is to skip CSRF check for GraphQL controller on prefab-feb-2 and apply same on prefab-feb3 later.
config/application.rb(autoload path fix already applied)app/services/database.rb,app/services/database/error_classes.rbapp/controllers/api/v2/database/build_sessions_controller.rb(CSRF skip already present viaskip_before_action :verify_authenticity_token)app/controllers/graphql_controller.rb(needs CSRF adjustment)- Frontend Apollo link:
app/frontend/common/create-apollo-link.ts. - Layout with csrf meta:
app/views/layouts/application.html.erb.
- Pull latest builder repo changes or copy modified files from prefab-feb-2 host.
- Run
docker-compose run --rm builder-web bundle exec rails zeitwerk:check. - Restart builder containers.
- Verify Database tab on prefab-feb3 domain via Chrome MCP.
- Decide on CSRF strategy for GraphQL controller; likely
skip_before_action :verify_authenticity_tokenorprotect_from_forgery with: :null_session. - Redeploy target or restart
target-webcontainer after change. - Reload Live Preview to confirm guestbook entries load without 422.
This document lives at /tmp/prefab-feb2-database.md on prefab-feb-2.