Commit 0121afb9 authored by Brooke Mosby's avatar Brooke Mosby

update validation

parent 191586d2
---
title: '`deploymentId` contains invalid characters'
---
## Why This Error Occurred
The `deploymentId` in your `next.config.js` contains characters that are not allowed. Only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (\_) are permitted.
## Possible Ways to Fix It
### Option 1: Remove Invalid Characters
Remove or replace any characters that are not alphanumeric, hyphens, or underscores:
```js
// ✅ Correct
module.exports = {
deploymentId: 'my-deployment-123', // Only alphanumeric, hyphens, underscores
}
// ❌ Incorrect
module.exports = {
deploymentId: 'my deployment 123', // Contains spaces
deploymentId: 'my.deployment.123', // Contains dots
deploymentId: 'my/deployment/123', // Contains slashes
deploymentId: 'my@deployment#123', // Contains special characters
}
```
### Option 2: Sanitize the Deployment ID
If you're generating the ID from user input or other sources, sanitize it to remove invalid characters:
```js
// next.config.js
module.exports = {
deploymentId: () => {
const rawId = process.env.DEPLOYMENT_ID || 'default-id'
// Remove all characters that are not alphanumeric, hyphens, or underscores
return rawId.replace(/[^a-zA-Z0-9_-]/g, '')
},
}
```
### Option 3: Use a Valid Format
Common valid formats include:
```js
// next.config.js
module.exports = {
// Using hyphens
deploymentId: 'my-deployment-id',
// Using underscores
deploymentId: 'my_deployment_id',
// Alphanumeric only
deploymentId: 'mydeployment123',
// Mixed format
deploymentId: 'my-deployment_123',
}
```
## Additional Information
- The deployment ID is used for skew protection and asset versioning
- Invalid characters can cause issues with URL encoding and routing
- Keep the ID URL-friendly by using only the allowed character set
- The validation ensures compatibility across different systems and environments
......@@ -980,5 +980,6 @@
"979": "invariant: expected %s bytes of postponed state but only received %s bytes",
"980": "deploymentId function must return a string. https://nextjs.org/docs/messages/deploymentid-not-a-string",
"981": "The deploymentId \"%s\" cannot start with the \"dpl_\" prefix. Please choose a different deploymentId in your next.config.js. https://vercel.com/docs/skew-protection#custom-skew-protection-deployment-id",
"982": "The deploymentId \"%s\" exceeds the maximum length of 32 characters. Please choose a shorter deploymentId in your next.config.js. https://nextjs.org/docs/messages/deploymentid-too-long"
"982": "The deploymentId \"%s\" exceeds the maximum length of 32 characters. Please choose a shorter deploymentId in your next.config.js. https://nextjs.org/docs/messages/deploymentid-too-long",
"983": "The deploymentId \"%s\" contains invalid characters. Only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_) are allowed. https://vercel.com/docs/skew-protection#custom-skew-protection-deployment-id"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment