Changing Content-Type header in wix-api

Hi Folks,
The default Content-Type for wix-apis is application/json, Can we change that ?
I tried setting it to text/html then also the Content-type is application /json.
let options = {
“headers”: {
“Content-Type”: “text/html; charset=utf-8”
},
“body”: “”
};
and then return ok(options);
Can we change the content type or is there another way to do this ?
Thanks.

Hi Prakazh,

Wix Code does not allow modifications to the page HTML - the site/page is sandboxed.

WixCode understands all of Javascript, except for anything that accesses the DOM.

This keeps the user from inadvertently “breaking” something. I myself tried to hack things from the code, from an iFrame, and in my dreams, but WixCode wasn’t having any of it.

Accessing document elements such as div, span, button, etc is off-limits. The way to access elements on the page is only through $w.

One small exception is the $w.HtmlComponent (which is based on an iFrame). This element was designed to contain vanilla HTML and it works just fine. You just can’t try to trick it by using parent, window, top, etc.

Yisrael

Hi Yisrael,

I was referring to the wix-api code to expose some APIs (plain HTML page).
Can you suggest something ?

Thanks.

The HTML of a Wix site page cannot be accessed or modified. The only way to access components and site functionality is by using the Wix Code APIs. Take a look at the Wix Code API overview to learn what capabilities are available. A good place to start learning is the Wix Code Basics .

For using HTML (with Javascript and CSS), you can use the HtmlComponent - just realize that it is sandboxed. You can also run Javascript using the Javascript evaluate() function. For an example of this, see the Javascript Playground example.

Have fun,

Yisrael