[GH-ISSUE #472] Auto-launching web page #396

Closed
opened 2026-02-28 01:25:06 +03:00 by kerem · 21 comments
Owner

Originally created by @bill-orange on GitHub (Dec 13, 2017).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/472

First off, thank you for the useful code. I am trying to make my efforts accessible to non-hobbyists and this helps. I do have a couple of questions.

  1. How the heck did you get the set-up page to launch automatically upon selection of the AP? Can you direct me to the segment of you code that accomplishes the feat? I would like to fork FSBrowser to do the same.

  2. Does any portion of your code continue to run in loop() in the most basic example? I have had an odd result with my iPhone using my existing code with your library. Once my code is up and running all is well connecting from a WIN10 machine. However, after a few minutes attempts to connect to the iPhone are unresponsive. Unless I made a subtle screw-up (likely) , there were no code changes except for removing smartconfig and substituting in your library, applies in the most basic way.

There are lots of issues by many people with ESP8266 web server and especially the Async server becoming unresponsive but this is especially weird.

IDE: Arduino IDE last non-beta release
Board: NODEMCU 9.0 @160 Mhz (with battery for stability)
Code; Its big, so here's a link https://1drv.ms/f/s!AmXKqAwyCrbxh90Ne_yQ-f9rJaa0Tw
What it should look like: http://orangecaweather.duckdns.org:8021

Thoughts?

Originally created by @bill-orange on GitHub (Dec 13, 2017). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/472 First off, thank you for the useful code. I am trying to make my efforts accessible to non-hobbyists and this helps. I do have a couple of questions. 1. How the heck did you get the set-up page to launch automatically upon selection of the AP? Can you direct me to the segment of you code that accomplishes the feat? I would like to fork FSBrowser to do the same. 2. Does any portion of your code continue to run in loop() in the most basic example? I have had an odd result with my iPhone using my existing code with your library. Once my code is up and running all is well connecting from a WIN10 machine. However, after a few minutes attempts to connect to the iPhone are unresponsive. Unless I made a subtle screw-up (likely) , there were no code changes except for removing smartconfig and substituting in your library, applies in the most basic way. There are lots of issues by many people with ESP8266 web server and especially the Async server becoming unresponsive but this is especially weird. IDE: Arduino IDE last non-beta release Board: NODEMCU 9.0 @160 Mhz (with battery for stability) Code; Its big, so here's a link https://1drv.ms/f/s!AmXKqAwyCrbxh90Ne_yQ-f9rJaa0Tw What it should look like: http://orangecaweather.duckdns.org:8021 Thoughts?
kerem closed this issue 2026-02-28 01:25:06 +03:00
Author
Owner

@tablatronix commented on GitHub (Dec 14, 2017):

Captiveportal() function, most devices automatically try to connect to a captuveportal test page in the background, it allows for alternative logins, look it up.

<!-- gh-comment-id:351592189 --> @tablatronix commented on GitHub (Dec 14, 2017): Captiveportal() function, most devices automatically try to connect to a captuveportal test page in the background, it allows for alternative logins, look it up.
Author
Owner

@jee1mr commented on GitHub (Dec 19, 2017):

@bill-orange The trick is to redirect all DNS requests to your own IP and if the request came for another domain then rewrite the URL to your IP. This way the device understands that there's a captive portal running and the OS pops it up natively.

Check L115: /* Setup the DNS server redirecting all the domains to the apIP /
and L704: /
* Redirect to captive portal if we got a request for another domain. Return true in that case so the page handler do not try to handle the request again. */

<!-- gh-comment-id:352698679 --> @jee1mr commented on GitHub (Dec 19, 2017): @bill-orange The trick is to redirect all DNS requests to your own IP and if the request came for another domain then rewrite the URL to your IP. This way the device understands that there's a captive portal running and the OS pops it up natively. Check L115: /* Setup the DNS server redirecting all the domains to the apIP */ and L704: /** Redirect to captive portal if we got a request for another domain. Return true in that case so the page handler do not try to handle the request again. */
Author
Owner

@alexiszecharies commented on GitHub (Jan 9, 2018):

how can i make it not pop up?

<!-- gh-comment-id:356433120 --> @alexiszecharies commented on GitHub (Jan 9, 2018): how can i make it not pop up?
Author
Owner

@tablatronix commented on GitHub (Jan 10, 2018):

In my dev branch
setCaptivePortalEnable

I hope to merge this fork soon (mine)

<!-- gh-comment-id:356476182 --> @tablatronix commented on GitHub (Jan 10, 2018): In my dev branch setCaptivePortalEnable I hope to merge this fork soon (mine)
Author
Owner

@alexiszecharies commented on GitHub (Jan 10, 2018):

I tried with your code and as you said it does not pop up. Nevertheless, when i put the IP 192.168.4.1 in the browser it does not find a webpage. How am i supposed to send the data?

<!-- gh-comment-id:356593055 --> @alexiszecharies commented on GitHub (Jan 10, 2018): I tried with your code and as you said it does not pop up. Nevertheless, when i put the IP 192.168.4.1 in the browser it does not find a webpage. How am i supposed to send the data?
Author
Owner

@tablatronix commented on GitHub (Jan 10, 2018):

Hmm, let me test

<!-- gh-comment-id:356642844 --> @tablatronix commented on GitHub (Jan 10, 2018): Hmm, let me test
Author
Owner

@tablatronix commented on GitHub (Jan 10, 2018):

I just committed a fix for that, thanks, sorry about that.

<!-- gh-comment-id:356648111 --> @tablatronix commented on GitHub (Jan 10, 2018): I just committed a fix for that, thanks, sorry about that.
Author
Owner

@alexiszecharies commented on GitHub (Jan 10, 2018):

Great, it worked. Thanks. There is a weird looking kind of button called No AP set. Should that be the behaviour?

<!-- gh-comment-id:356714938 --> @alexiszecharies commented on GitHub (Jan 10, 2018): Great, it worked. Thanks. There is a weird looking kind of button called No AP set. Should that be the behaviour?
Author
Owner

@tablatronix commented on GitHub (Jan 10, 2018):

Screenshot? Dev is not well tested

<!-- gh-comment-id:356726400 --> @tablatronix commented on GitHub (Jan 10, 2018): Screenshot? Dev is not well tested
Author
Owner

@tablatronix commented on GitHub (Jan 10, 2018):

Do you mean the well status?

<!-- gh-comment-id:356766436 --> @tablatronix commented on GitHub (Jan 10, 2018): Do you mean the well status?
Author
Owner

@alexiszecharies commented on GitHub (Jan 12, 2018):

screenshot from 2018-01-12 11 38 02

<!-- gh-comment-id:357380182 --> @alexiszecharies commented on GitHub (Jan 12, 2018): ![screenshot from 2018-01-12 11 38 02](https://user-images.githubusercontent.com/10675229/34899021-13c7a46a-f7d5-11e7-8de9-57cfa78fe566.png)
Author
Owner

@alexiszecharies commented on GitHub (Jan 12, 2018):

I meant the no AP set box

<!-- gh-comment-id:357380306 --> @alexiszecharies commented on GitHub (Jan 12, 2018): I meant the no AP set box
Author
Owner

@alexiszecharies commented on GitHub (Jan 12, 2018):

Also, I am trying to run an ajax call from a webpage (not from this portal) like this:

$.ajax({
method: 'POST',
url: 'http://192.168.4.1/wifisave',
data: {
's': 'PFCdud3',
'p': ''
},
success: function(){
alert('wow');
}
});

This works in the ESP, it connects. But it returns: Failed to load http://192.168.4.1/wifisave: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. Do you know how I can fix this?

<!-- gh-comment-id:357382776 --> @alexiszecharies commented on GitHub (Jan 12, 2018): Also, I am trying to run an ajax call from a webpage (not from this portal) like this: $.ajax({ method: 'POST', url: 'http://192.168.4.1/wifisave', data: { 's': 'PFCdud3', 'p': '' }, success: function(){ alert('wow'); } }); This works in the ESP, it connects. But it returns: Failed to load http://192.168.4.1/wifisave: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. Do you know how I can fix this?
Author
Owner

@tablatronix commented on GitHub (Jan 13, 2018):

Yeah thats the status its called a well

<!-- gh-comment-id:357387700 --> @tablatronix commented on GitHub (Jan 13, 2018): Yeah thats the status its called a well
Author
Owner

@tablatronix commented on GitHub (Jan 13, 2018):

You are running this from another page? This is illegal cross domain access, there are ways around it google cors

<!-- gh-comment-id:357388054 --> @tablatronix commented on GitHub (Jan 13, 2018): You are running this from another page? This is illegal cross domain access, there are ways around it google cors
Author
Owner

@alexiszecharies commented on GitHub (Jan 13, 2018):

Yes, but I need to change code from the side of the ESP , right?

<!-- gh-comment-id:357467950 --> @alexiszecharies commented on GitHub (Jan 13, 2018): Yes, but I need to change code from the side of the ESP , right?
Author
Owner

@tablatronix commented on GitHub (Jan 13, 2018):

Yeah not sure how you are gonna send that header without editing library, there are no callbacks available really.

<!-- gh-comment-id:357475348 --> @tablatronix commented on GitHub (Jan 13, 2018): Yeah not sure how you are gonna send that header without editing library, there are no callbacks available really.
Author
Owner

@tablatronix commented on GitHub (Jan 13, 2018):

We could implement jsonp perhaps

<!-- gh-comment-id:357475616 --> @tablatronix commented on GitHub (Jan 13, 2018): We could implement jsonp perhaps
Author
Owner

@alexiszecharies commented on GitHub (Jan 14, 2018):

That is a really good idea

<!-- gh-comment-id:357489602 --> @alexiszecharies commented on GitHub (Jan 14, 2018): That is a really good idea
Author
Owner

@alexiszecharies commented on GitHub (Jan 14, 2018):

Solved it by adding

server->sendHeader("Access-Control-Allow-Origin","*");
server->sendHeader("dataType","jsonp");

in WiFiManager::handleWifiSave.

<!-- gh-comment-id:357537983 --> @alexiszecharies commented on GitHub (Jan 14, 2018): Solved it by adding server->sendHeader("Access-Control-Allow-Origin","*"); server->sendHeader("dataType","jsonp"); in WiFiManager::handleWifiSave.
Author
Owner

@alexiszecharies commented on GitHub (Jan 15, 2018):

Do you know if it is not recommendable to use the function wifiManager.resetSettings() ?

<!-- gh-comment-id:357558061 --> @alexiszecharies commented on GitHub (Jan 15, 2018): Do you know if it is not recommendable to use the function wifiManager.resetSettings() ?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#396
No description provided.