Fetching data from non-https localhost

When developing on http://localhost:8080 (non-https) and trying to retrieve data using the JavaScript SDK, the response header access-control-allow-origin is set to HTTPS, so data cannot be retrieved. How can I work around this?

Hello @kokoro ,
Welcome to our community and thank you for trying out Backendless.

Can you provide an example of the JavaScript code you are using?

Regards, Nazar

Here’s summary of code(TypeScript):

import Backendless from "backendless"


const year = 2022
const month = 9
const day = 7
const queryBuilder = Backendless.DataQueryBuilder.create()
  .setWhereClause(`year = ${year} and month = ${month} and day = ${day}`)
const data = await Backendless.Data.of("diary")

Hi @kokoro

I just tried to run a simple app and it works for me, no CORS issues

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>JS-SDK Test CORS</title>
<script src="//api.backendless.com/sdk/js/latest/backendless.js"></script>

  const APP_ID = 'xxx'
  const API_KEY = 'xxx'

  Backendless.initApp(APP_ID, API_KEY)

  async function run() {
    const result = await Backendless.Data.of('Users').find()


where is your Backendless app located, in the EU cluster?

Maybe not in EU, my subdomain is heartycup.backendless.app.
I tried some patterns.

open as file (file:///Users/user/Downloads/backendless-cors/backendless-cors.html): success

access-control-allow-origin: * or access-control-allow-origin: null

open as server python3 -m http.server (http://[::]:8000/backendless-cors.html): success

access-control-allow-origin: http://[::]:8000

open as server python3 -m http.server (http://localhost:8000/backendless-cors.html): failed

access-control-allow-origin: https://localhost:8000

And I noticed that I can avoid this problem by using [::] instead of localhost. Thanks!

@kokoro ,

Thanks for the report. I was able to reproduce the problem. Internal ticket BKNDLSS-29654 created.
We will let you know when the problem has been fixed.


1 Like