Question (per title):
What are the requirements to be able to have the Import URL work successfully in a driver?
Longer version... None of my drivers are able to be successfully imported. I host them on my own domain, not Github. The URLs are all valid and copy/pasting them into a browser, then copy/pasting the ,groovy file displayed works fine, but it is extra steps and I would like to make it easier for users of my drivers. So... why will they not work? Does Hubitat only allow github sources? Does it require a particular MIME format? In one of my driver threads it was mentioned that maybe they were being served incorrectly and needed to be plain text. I have since added a MIME Type that should always serve files with the "groovy" extension as text/plain, so that does not seem to be the case.
Access to XMLHttpRequest at
'URL' from origin 'https://192.168.xx.xx' has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
@anon61068208: I also see you posted in gitlab about disabling the CORS policy...
So if this is a Server Side CORS issue... I have no idea how to solve it. I tried enabling CORS on my server by making an edit to the .htaccess file but it had no impact. Still does not import. The irritating thing is that the editor gives the warning it is going to override it and everything but absolutely nothing happens. Nothing is in any of the logs I know to access either so how would someone have any idea what is happening or why, or how to solve it.
Anything from anyone at Hubitat with a specific answer? This really does not feel like something that should ONLY work with github, but...
# This file is a template, and might need editing before it works on your project.
# Full project: https://gitlab.com/pages/plain-html
pages:
stage: deploy
script:
- mkdir .public
- cp -r Driver/* .public
- mv .public public
artifacts:
paths:
- public
only:
- master
So say your repo contains your groovy files under Driver/
This yaml will copy that folder to your pages location.
Once your page is created the URL to those groovy files will be in this format....
This only works using Gitlab though correct?
So another git. I am just serving the drivers from a basic website. It should not be so complicated or even CARE where it imports the code as long as it is basic text (MAYBE, and a valid URL of course).
So this still will not work for me unless I set up a git myself... But I will not bother. So either I discover another workaround, Hubitat answers with an alternative, or my drivers remain unable to be imported.
@anon61068208: Thanks for continuing to dig into this.
The files are in a basic folder, not being served by a particular page. There is no underlying php or such, nor even an HTML page. I just have the raw text .groovy files. The only references to them are links from here, an HTML file with links from my domain, and then Import links (in the drivers and in the version.xml file I keep in that same folder).
In any case, I altered the .htaccess to allow CORS per the Apache settings a long time ago (when I was last trying this): Enable CORS
At the same time I made "groovy" as a text/plain content type as well... Although I just altered that to be ".groovy". But that does not seem to have changed anything.
WHAT?! I tried to Import again last night (changed one of my drivers to say "hi" at the beginning just to test it, with no success. I just tried this morning after seeing your comments and it worked, for the first time EVER.
I made that one change to make it ".groovy" vs "groovy" last night... maybe the server took a bit to migrate the change?
So it was the "." that mattered... 6 months... and all I needed was a ".".
Thanks for bearing with me and prompting me to check again!