JavaScript not loading with custom URL

0
Hi! I’m coming across something strange and I was hoping you all would be able to help. JavaScript seems to be prevented from loading if the Mendix application has a different/custom URL. For instance, localhost:8080’s JavaScript works just fine, but localhost:8080/p/CustomURL will not load any JavaScript (From changing the URL field in the Edit Page popup.) Would you happen to know what causes this and how to fix it? Thanks!
asked
2 answers
0

Update:

I still couldn’t find the cause, but I found a roundabout fix for anyone who has this problem in the future. Redirect/send the user to a new page and add the URL Redirector from the App Store. Set ‘URL (prefix)’ to a forward slash (/) and leave the rest of the information the same. Now carry on as you normally do in your app.

Although this may add a tiny bit of time to the user’s experience, the JavaScript now seems to work since we’re back to the base URL. If anyone still has any more information, it is much appreciated!

answered
0

If you refer to Javascript that is in the index.html, please check the following:

- Is there a slash '/' in front of the javascript? If not, put a slash in front of it. That way it will load from root
- There is also a settings.json where you need to put the slash in front of the css path

The reason for this is that the browser will try to load your Javascript from a relative path. So it would load 'localhost:8080/p/path_of_javascript', instead of 'localhost:8080/path_of_javascript'.

I have seen this issue with CSS and styling, I figure that's the same issue with Javascript

answered