Report this

What is the reason for this report?

How to setup a Parse Server that uses Spaces CDN?

Posted on December 16, 2019

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('https://fra1.digitaloceanspaces.com');
//Define S3 options
var s3Options = {
  bucket: 'bucket',
  baseUrl: 'https://bucket.fra1.digitaloceanspaces.com',
  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!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.