Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ NUXT_CONTENTSTACK_API_KEY=your_api_key_here
NUXT_CONTENTSTACK_DELIVERY_TOKEN=your_delivery_token_here
NUXT_CONTENTSTACK_PREVIEW_TOKEN=your_preview_token_here
NUXT_CONTENTSTACK_ENVIRONMENT=preview
NUXT_CONTENTSTACK_REGION=EU
NUXT_CONTENTSTACK_REGION=EU # Options: NA, EU, AU, AZURE-NA, AZURE-EU, GCP-NA, GCP-EU
NUXT_CONTENTSTACK_PREVIEW=true
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,48 @@ NUXT_CONTENTSTACK_ENVIRONMENT=preview
NUXT_CONTENTSTACK_PREVIEW=true
```

## Regions and endpoint configuration

Set `NUXT_CONTENTSTACK_REGION` to the region your Contentstack account is on. The value is case-insensitive.

| Region | Value |
|---|---|
| AWS North America | `NA` or `US` |
| AWS Europe | `EU` |
| AWS Australia | `AU` |
| Azure North America | `AZURE-NA` |
| Azure Europe | `AZURE-EU` |
| GCP North America | `GCP-NA` |
| GCP Europe | `GCP-EU` |

> Not sure which region you're on? Check your Contentstack dashboard URL — `eu-app.contentstack.com` means EU, `app.contentstack.com` means NA. Free developer accounts are on EU.

All API endpoints (content delivery, live preview, Visual Builder) are automatically resolved from your region. You do not need to set them manually.

The following endpoint keys are resolved per region and available if you ever need them directly via `getContentstackEndpoint` from `@contentstack/utils`:

| Key | NA value |
|---|---|
| `contentDelivery` | `cdn.contentstack.io` |
| `preview` | `rest-preview.contentstack.com` |
| `application` | `app.contentstack.com` |
| `graphqlDelivery` | `graphql.contentstack.com` |
| `graphqlPreview` | `graphql-preview.contentstack.com` |
| `images` | `images.contentstack.io` |
| `assets` | `assets.contentstack.io` |
| `contentManagement` | `api.contentstack.io` |
| `auth` | `auth-api.contentstack.com` |

### Custom or dedicated environments

If your Contentstack account runs on a dedicated or private cloud instance, the standard region-based endpoints may not apply. In that case, override each endpoint individually using these environment variables. **Only set these if instructed by Contentstack support — standard accounts should leave them unset.**

```bash
NUXT_CONTENTSTACK_CONTENT_DELIVERY=your-custom-cdn.example.com
NUXT_CONTENTSTACK_PREVIEW_HOST=your-custom-preview.example.com
NUXT_CONTENTSTACK_CONTENT_APPLICATION=your-custom-app.example.com
```

## Turn on Live Preview

Go to Settings > Live Preview. Click enable and select the `Preview` environment in the drop down. Hit save.
Expand Down
17 changes: 8 additions & 9 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
// https://nuxt.com/docs/api/configuration/nuxt-config

import { getContentstackEndpoints, getRegionForString } from "@timbenniks/contentstack-endpoints";
const region = getRegionForString(process.env.NUXT_CONTENTSTACK_REGION as string)
const endpoints = getContentstackEndpoints(region, true)
import { getContentstackEndpoint, type ContentstackEndpoints } from "@contentstack/utils";
const endpoints = getContentstackEndpoint(process.env.NUXT_CONTENTSTACK_REGION || 'us', '', true) as ContentstackEndpoints

export default defineNuxtConfig({
compatibilityDate: '2024-04-03',
devtools: { enabled: true },
modules: ['@nuxtjs/tailwindcss'],
runtimeConfig: {
// Certain API endpoints can be set via environment variables for internal testing at Contentstack
// You can omit in your project. Use @timbenniks/contentstack-endpoints to get the right urls for your region.
// Certain API endpoints can be set via environment variables for custom or dedicated Contentstack environments.
// You can omit these in your project. Use @contentstack/utils getContentstackEndpoint to get the right urls for your region.
public: {
apiKey: process.env.NUXT_CONTENTSTACK_API_KEY,
deliveryToken: process.env.NUXT_CONTENTSTACK_DELIVERY_TOKEN,
previewToken: process.env.NUXT_CONTENTSTACK_PREVIEW_TOKEN,
environment: process.env.NUXT_CONTENTSTACK_ENVIRONMENT,
preview: process.env.NUXT_CONTENTSTACK_PREVIEW === "true",
region: region ? region : process.env.NUXT_CONTENTSTACK_REGION as any,
contentDelivery: process.env.NUXT_CONTENTSTACK_CONTENT_DELIVERY || endpoints && endpoints.contentDelivery,
previewHost: process.env.NUXT_CONTENTSTACK_PREVIEW_HOST || endpoints && endpoints.preview,
applicationHost: process.env.NUXT_CONTENTSTACK_CONTENT_APPLICATION || endpoints && endpoints.application
region: process.env.NUXT_CONTENTSTACK_REGION as any,
contentDelivery: process.env.NUXT_CONTENTSTACK_CONTENT_DELIVERY || endpoints.contentDelivery as string,
previewHost: process.env.NUXT_CONTENTSTACK_PREVIEW_HOST || endpoints.preview as string,
applicationHost: process.env.NUXT_CONTENTSTACK_CONTENT_APPLICATION || endpoints.application as string
},
},
})
Loading
Loading