You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
- Deploy to various supported providers with minimal configuration.
25
25
- Use infrastructure from code to keep your environment consistent.
26
26
27
+
### About API Routes
28
+
29
+
API route rewrites (under `/api`) are **only enabled if you have at least one website defined** in your project.
30
+
We are exploring options to allow enabling API routing independently of websites in the future.
31
+
27
32
## Enabling Websites
28
33
29
34
Websites are currently in [Preview](/reference/preview-features). To enable this feature in your project add the following to your `nitric.yaml` file.
@@ -94,23 +99,50 @@ websites:
94
99
url: http://localhost:4323
95
100
```
96
101
102
+
## Why Are All Sites Behind a Single Domain?
103
+
104
+
Currently, Nitric serves all websites behind a single domain to simplify deployment and management. This approach ensures that your API and website can coexist without CORS issues and allows for relative path usage in your frontend code. Additionally, serving all sites behind a single domain can reduce costs associated with managing multiple domains.
105
+
106
+
At this time, configuring multiple domains for different websites is not supported. However, we understand the need for this feature and may support multiple domains in the future.
107
+
97
108
## Conflicting Routes
98
109
99
110
If you have conflicting routes between your API and website or between multiple sub-sites, you can configure the `path` for each website to avoid conflicts.
100
111
112
+
### What Happens If There Are Overlapping Paths?
113
+
114
+
If Nitric detects overlapping paths between websites, an error will be raised during development and deployment.
115
+
116
+
However, client-side routes (like React Router) are not detected at deployment time — so be careful when designing single-page apps to avoid unexpected overlaps.
117
+
101
118
### Reserved Paths
102
119
103
120
The following paths are reserved for use by the Nitric framework and cannot be used as website paths:
104
121
105
-
- `/api`used to rewrite API requests
122
+
- `/api`- used to rewrite API requests
123
+
124
+
We are looking at making the **rewrite path configurable** in the future, so you will have more flexibility in defining your own path structure.
106
125
107
126
## API Routes
108
127
109
-
Nitric automatically serves your API under the `/api` path. You can access your API routes at `https://<your-site>/api/<your-api>/<your-route>`.
128
+
If you have at least **one website enabled**, Nitric automatically serves your API under the `/api` path.
110
129
111
-
By serving your API under the same domain as your website, you avoid CORS issues and can use relative paths to access your API.
130
+
You can access your API routes at:
112
131
113
-
Here is an example of calling an API route from your website:
API route rewrites are **only enabled if you have at least one website defined** in your project.
139
+
We are exploring options to allow enabling API routing **without requiring a website** in the future.
140
+
141
+
### Why This Approach?
142
+
143
+
By serving your API under the same domain as your website, you avoid **CORS issues** and can use **relative paths** to access your API directly from your frontend code.
144
+
145
+
### Example API Call
114
146
115
147
```javascript
116
148
async function fetchData() {
@@ -121,6 +153,17 @@ async function fetchData() {
121
153
}
122
154
```
123
155
156
+
## Support for Frameworks like Next.js
157
+
158
+
If you're new to deploying websites with Nitric, you might wonder whether frameworks like **Next.js** will work by default.
159
+
160
+
- **Built static websites** (where your framework generates static assets, such as HTML, CSS, and JS files) are fully supported.
161
+
- **Server-side rendering (SSR)** and **framework-specific API routes** (like Next.js API routes) are **not currently supported**.
162
+
163
+
If you are using **Next.js**, you can follow the official guide on [static exports](https://nextjs.org/docs/app/building-your-application/deploying/static-exports) to generate a fully static version of your site.
164
+
165
+
We are actively exploring options to **support server-side applications**, including frameworks like Next.js, in the future.
0 commit comments