How to setup a Parse Server that uses Spaces CDN?

Posted December 16, 2019 1k views
DigitalOcean Spaces

I just setup my first Space, connected my Parse Server to it and everything works, but I’m not sure I have enabled anything CDN-wise, or if I have to.

I’m using the configuration below

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var S3Adapter = require('parse-server').S3Adapter;
var AWS = require("aws-sdk");

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;

//Set Digital Ocean Spaces EndPoint
const spacesEndpoint = new AWS.Endpoint('');
//Define S3 options
var s3Options = {
  bucket: 'bucket',
  baseUrl: '',
  region: 'fra1',
  directAccess: true,
  globalCacheControl: "public, max-age=31536000",
  s3overrides: {
    accessKeyId: 'accessKeyId',
    secretAccessKey: 'secretAccessKey',
    endpoint: spacesEndpoint

var s3Adapter = new S3Adapter(s3Options);

var api = new ParseServer({
  publicServerURL: 'http://ip:1338/parse',
  filesAdapter: s3Adapter

Any thoughts will be much appreciated!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

No sir.Please use this:<bucketName>.<region> if you use as endpoint,you can just use <region>,CDN is not allowed.