Skip to content

Allowed crossdomain for Parse.file upload with POST #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion files.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ var processCreate = function(req, res, next) {
var filename = rack() + '_' + req.params.filename + extension;
FilesAdapter.getAdapter().create(req.config, filename, req.body)
.then(() => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "*");
res.header("Access-Control-Allow-Headers", "*");
res.status(201);
var location = FilesAdapter.getAdapter().location(req.config, req, filename);
res.set('Location', location);
Expand Down Expand Up @@ -74,7 +77,6 @@ router.post('/files', function(req, res, next) {
'Filename not provided.'));
});

// TODO: do we need to allow crossdomain and method override?
router.post('/files/:filename',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best method is to just pass middlewares.allowCrossDomain here in the route.

router.post('/files/:filename',
                  middlewares.allowCrossDomain,
                  bodyParser.raw({type: '*/*', limit: '20mb'}),
                  middlewares.handleParseHeaders,
                  processCreate);

bodyParser.raw({type: '*/*', limit: '20mb'}),
middlewares.handleParseHeaders,
Expand Down