Skip to main content
Version: 0.10

HTTP fetch

Make requests to allow-listed external domains.

Your Devvit app can make network requests to access allow-listed external domains using HTTP Fetch. This enables your app to leverage webhooks, personal servers, and other third-party integrations asynchronously across the network.

Devvit configure

import { Devvit } from '@devvit/public-api';

Devvit.configure({
http: true,
// other capabilities
});

Limitations

  • Access is only allowed to https URIs.
  • Supported HTTP methods: GET, POST, PUT, DELETE, OPTIONS and PATCH.
  • HTTP timeout limit is 30 seconds.

To request a domain to the allow-list, please contact us via r/devvit modmail or fill out this form.

Example

import { Devvit } from '@devvit/public-api';

Devvit.configure({ http: true });

Devvit.addMenuItem({
location: 'comment',
label: 'Sample HTTP request',
onPress: async (_, context) => {
const { commentId, ui } = context;
console.log(`Comment ID: ${commentId}`);
const response = await fetch('https://example.com', {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ content: commentId }),
});
ui.showToast(
`Invoked HTTP request on comment: ${commentId}. Completed with status: ${response.status}`
);
},
});

export default Devvit;

Troubleshooting

If you see the following error, it means HTTP Fetch requests are hitting the internal timeout limits. To resolve this:

  • Use a queue or kick off an async request in your back end. You can use Scheduler to monitor the result.
  • Optimize the overall HTTP request latency if you have a self-hosted server.
HTTP request to domain: <domain> timed out with error: context deadline exceeded.

Terms and Conditions

Any app that uses fetch must upload Terms and Conditions and a Privacy Policy. Links to each of these documents must be saved in the app details form.

app details form