08Cloud Storage
Allowed websites (CORS) for browser access to buckets
CORS error on upload or playback from the browser? Add your website as an allowed website for a bucket in Nexthosting Cloud Storage, step by step.
In short
If you want your visitors’ browsers to work with a bucket directly, for example to upload or play videos, add your website in the bucket settings under Allowed websites (Erlaubte Websites). This is the CORS permission. It grants no access rights: every request still needs a valid key or signed link, and your files stay private.
Why do I need this?
Section titled “Why do I need this?”Browsers normally do not allow a website to load data from, or send data to, a different server. The mechanism behind this is called CORS. If you see a message such as “blocked by CORS policy” or “No Access-Control-Allow-Origin header” in the browser console when your page accesses s3.nexthosting.net, the entry is missing from this list.
Typical cases:
- Your website loads videos or images from a bucket and plays them with a player (for example hls.js).
- Your form uploads files straight from the browser into a bucket (upload via a signed link).
- A web app reads data from a bucket with JavaScript.
You do not need this permission for programs outside the browser (rclone, aws-cli, SFTP), for the storage panel itself, or for normal share links used to download files.
Add a website
Section titled “Add a website”Only the owner of the bucket can change the list, not members.
- In the panel, open Files (Dateien) and then the bucket you want.
- Click Bucket settings (Einstellungen des Buckets). The dialog is called “Einstellungen für …” (Settings for …).
- In the Allowed websites section, enter one address per line, for example
https://meine-seite.de. - Click Save websites (Websites speichern).
Rules for the entries:
| Rule | Example |
|---|---|
Format https://host or http://host, with a port if needed |
https://meine-seite.de, http://localhost:3000 |
| Only the address, no path | https://meine-seite.de instead of https://meine-seite.de/seite |
www is a separate address |
https://www.meine-seite.de needs its own line |
| At most 10 entries per bucket |
The list applies to this bucket. Add your website separately for every bucket it accesses from the browser. If the bucket is deleted or the contract ends, the list disappears with it.
How your website accesses the bucket
Section titled “How your website accesses the bucket”A website uses signed links (pre-signed requests, “presigned URLs”) for browser access. Your server creates them with an S3 access, and the website uses them. The access stays on the server and never goes into browser code.
Both address styles work:
https://s3.nexthosting.net/mein-bucket/video/lektion1.m3u8https://mein-bucket.s3.nexthosting.net/video/lektion1.m3u8Example of an upload from the browser in JavaScript. Your server created the address signierteAdresse with its S3 access:
const antwort = await fetch(signierteAdresse, { method: 'PUT', body: datei, headers: { 'Content-Type': datei.type },});if (!antwort.ok) throw new Error('Upload failed');How to create an S3 access is explained in Access keys and connecting. Give the access only the permissions it needs, and restrict it to the bucket or a folder.
Frequently asked questions
Section titled “Frequently asked questions”I added the website but still get a CORS error.
Section titled “I added the website but still get a CORS error.”Check these points: Is the address exactly as it appears in the browser address bar (with https://, without a path, with or without www)? Is the right bucket selected? The entry applies to requests to this bucket and to both address styles. Reload the page after saving, because browsers cache CORS responses for a short time.
Do I need to set anything up in the customer account or via a ticket?
Section titled “Do I need to set anything up in the customer account or via a ticket?”No. You add the websites yourself in the panel.
May I enter * (all websites)?
Section titled “May I enter * (all websites)?”No, only specific addresses are possible.
Are my files public now?
Section titled “Are my files public now?”No. The permission only allows the browser to read the response. Without a valid key or signed link, nobody gets a file.