Server side JS not working


(Mitch Kerry) #1

5.4.5.1
Hi all

Is there any reason server side JS won’t run?
Even something simple as
<script runat="server"> print('<h1>%asset_name%</h1>'); </script>
won’t show anything.
Is there a system config or something I need to do?

Thanks


(David Schoen) #2

At the moment the best way to check if Matrix can execute JS correctly is to create a REST Resource asset (might still be called “REST Resource JavaScript” in 5.4.5.1 I’m not sure) and check whether either of the engines can be chosen without a warning showing.

E.g warning showing for SpiderMonkey:

Clean V8JS install:

These are the same engines SSJS will try to use.


(Mitch Kerry) #3

Thanks

We are using those in the site, and a fresh one did not bring back any errors.
So seems that JS can execute?


(David Schoen) #4

As long as the REST Resource doesn’t show a warning when selecting one of the JS engines, the SSJS example you gave should execute ok in a standard page.

Perhaps check Matrix’s error.log when rendering the front end page?


(Mitch Kerry) #5

Hi

Thanks for that…looks like I had another ss script that was erroring and blocking this one :slight_smile: