since the user is passed in params, and in POST they're sent as a JSON body, we need to: 1) parse the params from the JSON manually, Sinatra doesn't do that 2) add an OPTIONS route for the CORS preflight
···2627 def get_user_did
28 if settings.development?
29- if did = params[:user]
0000000030 return did
31 else
32 halt json_error('AuthMissing', 'Missing "user" parameter', status: 401)
···113 end
114115 json_response(terms: query.terms, posts: post_uris, cursor: items.last&.cursor)
0000000116 end
117118 post '/xrpc/blue.feeds.lycan.startImport' do
···2627 def get_user_did
28 if settings.development?
29+ did = if request.post?
30+ json = JSON.parse(request.body.read)
31+ request.body.rewind
32+ json['user']
33+ else
34+ params[:user]
35+ end
36+37+ if did
38 return did
39 else
40 halt json_error('AuthMissing', 'Missing "user" parameter', status: 401)
···121 end
122123 json_response(terms: query.terms, posts: post_uris, cursor: items.last&.cursor)
124+ end
125+126+ if settings.development?
127+ options '/xrpc/blue.feeds.lycan.startImport' do
128+ headers['Access-Control-Allow-Origin'] = '*'
129+ headers['Access-Control-Allow-Headers'] = 'content-type'
130+ end
131 end
132133 post '/xrpc/blue.feeds.lycan.startImport' do