Nuxt API

getNitroOrigin()

Last updated by
Harlan Wilton
in chore: sync.

A utility function to get the Nitro origin from the request headers.

This is a replacement for useRequestOrigin() which has edge-cases issues in development, prerendering and in some runtime environments.

The nitro origin acts as the canonical origin for the site when a url has not been provided.

Usage

import { getNitroOrigin } from '#imports'

const origin = getNitroOrigin()
// https://www.example.com
Did this page help you?