Thanks to visit codestin.com
Credit goes to roxyapi.com

Skip to content
  1. Docs
  2. Integrations
  3. Lovable

Lovable astrology app, Cloud Secrets and Edge Functions

Ship a horoscope page, a natal chart form, or a tarot reading inside a Lovable app in about twenty minutes, with the API key in Cloud Secrets and never in the browser.

Lovable writes the integration for you. Your job is three things, in this order: give the agent the truth sources so it stops guessing at endpoints, put the key where only an Edge Function can read it, then check the handful of lines that decide whether the key stays private.

1. Put the truth sources in project knowledge

Knowledge is a plain text field Lovable reads on every message, so this belongs there rather than in one chat turn. Open Project settings, Knowledge and paste the block below. The field holds up to 10,000 characters, which is far more than this needs.

RoxyAPI: one REST API for astrology, Vedic astrology, forecasting, human design, numerology, tarot and 18+ insight domains on one key. Base URL https://roxyapi.com/api/v2. Auth is the X-API-Key header, read from the ROXY_API_KEY Cloud secret, sent from an Edge Function only.

Where the truth lives, in this order:
1. The docs MCP server at https://roxyapi.com/mcp/docs. Streamable HTTP, no key, one tool: search_docs. Search it before every endpoint, field, SDK method and integration step.
2. https://roxyapi.com/AGENTS.md, read in full before any code. Auth rules, the location-first rule, request body shapes, the error contract, field formats, domain gotchas.
3. The OpenAPI spec, one per domain at https://roxyapi.com/api/v2/{domain}/openapi.json, where the paths are relative to the domain. Read one domain spec, never the combined one at https://roxyapi.com/api/v2/openapi.json: that is 259+ endpoints of schema.
4. No MCP available? Fetch https://roxyapi.com/llms.txt instead.

Rules that do not bend:
- Never say RoxyAPI lacks a feature without searching those first. Never guess a path: a 404 returns a suggestion field with the closest valid one.
- Every chart, horoscope, panchang, dasha and compatibility call needs latitude, longitude and timezone. Resolve them with GET /location/search?q={city} first and pass its timezone through. Never ask a person for coordinates.
- A 200 is clean JSON with no wrapper. Errors are { error, code }, and a 400 carries issues[] with every field problem at once. Retry only 429 and 5xx.
- Add ?lang= for any of en, tr, de, es, hi, pt, fr, ru, zh-Hans, zh-Hant. Machine values stay English; human text translates.

If your project is synced to Git, a root-level AGENTS.md works too: Lovable reads one on every session regardless of length.

Lovable can also query the docs server itself while it builds. Open Connectors, click + at the top right of the catalog, choose MCP server, give it a name, set the server URL to https://roxyapi.com/mcp/docs, pick No authentication, and click Add server. Chat connectors are personal to you and are never part of the published app, so this is a lookup channel for the agent, not a runtime dependency.

2. Put the key in Cloud Secrets

Lovable usually asks. When a feature needs a credential it opens a secure input in the chat and stores what you type as a project secret. To add it yourself, open More, Cloud, Secrets in the project toolbar, click Add secret, name it ROXY_API_KEY, and paste the value from your account.

Secrets are encrypted, injected into your Edge Functions at runtime, and never reach the browser. They are also write-only: once saved the value cannot be read back out of Lovable, only replaced or deleted. Keep your own copy, and note that manually added secrets are not carried over when a project is remixed.

Never name it VITE_ROXY_API_KEY. Any VITE_ prefixed value is a build-time browser value that gets inlined into the client bundle, which is why Lovable rejects that prefix in Secrets. If a page genuinely has no server side, the answer is not a secret key at all: mint a publishable pk_ key locked to your origin at your account and use the widgets.

3. Ask for the feature

Describe what you want in the chat. For a whole app rather than one feature, copy a ready prompt from AI prompts: Add RoxyAPI to an existing app is the one that fits Lovable, because it makes the agent pick the endpoint from the spec, keep the key server side, and prove the call before it stops.

Two Lovable-specific lines worth adding to any request:

  • Put the RoxyAPI call in an Edge Function that reads Deno.env.get('ROXY_API_KEY'), and have the React page call the Edge Function URL, never roxyapi.com.
  • Ask me for the ROXY_API_KEY secret if it is not set yet.

Check what Lovable built

Lovable writes and deploys Edge Functions as part of building the feature; there is no create button. Find them under More, Cloud, Edge functions, where Copy URL gives you the endpoint and View code opens the source. Four things to confirm before you publish:

  1. The key is read with Deno.env.get('ROXY_API_KEY'), never a string literal.
  2. The header is X-API-Key, not Authorization: Bearer.
  3. No React file mentions the key or calls roxyapi.com directly.
  4. The function passes the upstream status through on failure instead of swallowing it.

Prove the key works before you blame the generated code:

curl "https://roxyapi.com/api/v2/astrology/horoscope/aries/daily" \
  -H "X-API-Key: $ROXY_API_KEY"

Anything with a birth chart needs a place first

Every chart, panchang, dasha, compatibility and synastry call needs latitude, longitude and timezone. A second Edge Function proxying GET /location/search?q={query} gives you all three from a city name, so nobody has to type coordinates.

The search returns { total, limit, offset, cities }, and each city carries city, province, country, iso2, latitude, longitude, timezone and utcOffset. Feed latitude, longitude and timezone straight into POST /astrology/natal-chart alongside date as YYYY-MM-DD and time as HH:MM:SS. timezone takes an IANA name such as "Europe/London", which the server resolves to the daylight-saving-correct offset for that date, or decimal hours such as 5.5.

Debounce the city input at 300ms and the whole thing costs one call per chart.

Cache the daily calls

Lovable Cloud includes a Postgres database, and daily content is the same for every visitor. Ask for a daily_cache table keyed by sign, date and language, with the Edge Function reading the cache first and calling RoxyAPI only when the row is missing or older than 24 hours. Without it, one popular page burns a month of quota in an afternoon.

The five fixes

What went wrongWhat to say in chat
Fetch straight from ReactMove the RoxyAPI fetch into an Edge Function that reads ROXY_API_KEY with Deno.env.get, and call the function URL from the component.
The key inlined in codeSearch the project for the literal key string and replace it with Deno.env.get('ROXY_API_KEY').
Authorization: BearerRoxyAPI authenticates with the X-API-Key header. Update every fetch.
No error handlingReturn the upstream status and the { error, code } body. 401 is the key, 429 is quota, 400 carries issues[].
Missing CORS headersAdd the allow-origin and allow-headers response headers and answer the OPTIONS preflight with a 200.

Gotchas

  • Backend only key. A secret sk_ key is readable from Edge Functions and nowhere else. Browser code gets a publishable pk_ key locked to your origin, or nothing.
  • Never paste the key into the chat body. The agent needs the secret name, not the value. Use the secure input Lovable opens for you.
  • Secrets are write-only and are not copied on remix. Losing the value means minting a new key at your account.
  • Do not add .env to .gitignore in a Lovable project. Lovable needs it committed so build-time VITE_ values reach previews. Your RoxyAPI key is not in there.
  • Reserved prefixes. Names starting SUPABASE_ or LOVABLE_ are managed by the platform and cannot be created in Secrets. ROXY_API_KEY is clear of both.
  • Prefer IANA timezones. "America/New_York" resolves to the correct offset for the birth date. A decimal offset such as -5 knows nothing about daylight saving.
  • Edge Functions stop while a project is paused, and every feature that depends on them stops with them.

What to build next