Resource interpreted as Font but transferred with MIME type application/x-font-woff - qooxdoo

I followed the Web Fonts tutorial in qooxdoo documentation to add a web font to Font.js , but I notice there is a warning in Chrome's Developer Console:
My code is as follow:
/* ************************************************************************
#asset(myApp/fonts/*)
************************************************************************ */
qx.Theme.define("myApp.theme.Font",
{
extend : qx.theme.simple.Font,
fonts :
{
"silkscreen" :
{
size: 8,
lineHeight: 1,
family: [ "silkscreen", "Tahoma" ],
sources:
[
{
family: "Silkscreen",
source:
[
"myApp/fonts/slkscr-webfont.eot",
"myApp/fonts/slkscr-webfont.ttf",
"myApp/fonts/slkscr-webfont.woff",
"myApp/fonts/slkscr-webfont.svg#silkscreen"
]
}
]
}
}
});
How can I resolve the browser warning ?

According to the W3C spec, the correct MIME type is application/font-woff, so you need to configure your web server to use that when serving .woff files.

If you are using an IIS webserver, give this a try:
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>

Related

Communicating from react front-end with ASP.NET Core Web API on the same remote hosting panel

I have an independent react front-end and ASP.NET Core Web API (back-end) working and communicating fine on localhost. i created ClientApp folder in webApi project and copied whole react app in it.
then followed #Ringo answer on similar problem which is here
I changed the urls in both the frontend and backend from https://localhost:3000 to https://www.virtualcollege.pk.
but it's not working on remote here is link
The program.cs is:
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace WebApi
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>()
.UseUrls("https://www.virtualcollege.pk");
});
}
}
The startup.cs:
using AutoMapper;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WebApi.Helpers;
using WebApi.Services;
namespace WebApi
{
public class Startup
{
private readonly IWebHostEnvironment _env;
private readonly IConfiguration _configuration;
public Startup(IWebHostEnvironment env, IConfiguration configuration)
{
_env = env;
_configuration = configuration;
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// use sql server db in production and sqlite db in development
services.AddDbContext<DataContext>();
services.AddDbContext<CourseDbContext>();
services.AddCors();
services.AddControllers();
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
// configure strongly typed settings objects
var appSettingsSection = _configuration.GetSection("AppSettings");
services.Configure<AppSettings>(appSettingsSection);
// configure jwt authentication
var appSettings = appSettingsSection.Get<AppSettings>();
var key = Encoding.ASCII.GetBytes(appSettings.Secret);
services.AddAuthentication(x =>
{
x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(x =>
{
x.Events = new JwtBearerEvents
{
OnTokenValidated = context =>
{
var userService = context.HttpContext.RequestServices.GetRequiredService<IUserService>();
var userId = int.Parse(context.Principal.Identity.Name);
var user = userService.GetById(userId);
if (user == null)
{
// return unauthorized if user no longer exists
context.Fail("Unauthorized");
}
return Task.CompletedTask;
}
};
x.RequireHttpsMetadata = false;
x.SaveToken = true;
x.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(key),
ValidateIssuer = false,
ValidateAudience = false
};
});
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
// configure DI for application services
services.AddScoped<IUserService, UserService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext dataContext)
{
// migrate any database changes on startup (includes initial db creation)
dataContext.Database.Migrate();
app.UseRouting();
// global cors policy
app.UseCors(x => x
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapControllers());
//add this
app.UseStaticFiles();
if (!env.IsDevelopment())
{
app.UseSpaStaticFiles();
}
app.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA
// see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = "ClientApp";
if (_env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});
}
}
}
The front end webpack.config.json is:
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
resolve: {
extensions: ['.js', '.jsx']
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader'
}
]
},
plugins: [new HtmlWebpackPlugin({
template: './src/index.html'
})],
devServer: {
historyApiFallback: true
},
output:{
filename: '[name]-bundle.js',
},
externals: {
// global app config object
config: JSON.stringify({
apiUrl: 'https://www.virtualcollege.pk'
})
}
}
I have tried many ports, either front-end works or back-end.if i use following web.config file back-end works but no index.html is return by server.
web.config is here:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\WebApi.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="outprocess" />
<httpErrors>
<remove statusCode="502" subStatusCode="-1" />
<remove statusCode="501" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="412" subStatusCode="-1" />
<remove statusCode="406" subStatusCode="-1" />
<remove statusCode="405" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="403" subStatusCode="-1" />
<remove statusCode="401" subStatusCode="-1" />
<remove statusCode="400" />
<error statusCode="400" path="D:\inutpub\virtualcollege.pk\error_docs\bad_request.html" />
<remove statusCode="407" />
<error statusCode="407" path="D:\inutpub\virtualcollege.pk\error_docs\proxy_authentication_required.html" />
<remove statusCode="414" />
<error statusCode="414" path="D:\inutpub\virtualcollege.pk\error_docs\request-uri_too_long.html" />
<remove statusCode="415" />
<error statusCode="415" path="D:\inutpub\virtualcollege.pk\error_docs\unsupported_media_type.html" />
<remove statusCode="503" />
<error statusCode="503" path="D:\inutpub\virtualcollege.pk\error_docs\maintenance.html" />
<error statusCode="401" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\unauthorized.html" />
<error statusCode="403" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\forbidden.html" />
<error statusCode="404" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\not_found.html" />
<error statusCode="405" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\method_not_allowed.html" />
<error statusCode="406" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\not_acceptable.html" />
<error statusCode="412" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\precondition_failed.html" />
<error statusCode="500" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\internal_server_error.html" />
<error statusCode="501" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\not_implemented.html" />
<error statusCode="502" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\bad_gateway.html" />
</httpErrors>
</system.webServer>
</location>
</configuration>
if i use default web.config file already present httpdocs the front-end works but api calls do no work.
Thanks in advance for any help
here i have added screenshot when started on localhost by using url:https:localhost:4000 it started working fine after showing following error:
but when deploy to remote server it shows :www.virtualcollege.pk is currently unable to handle this request.http error 500
here is the launchsettings.json:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://localhost/WebApi",
"sslPort": 0
},
"iisExpress": {
"applicationUrl": "http://localhost:61907/",
"sslPort": 0
}
},
"profiles": {
"Development": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
i am sharing so that it may be helpful for others, after days of try and error i found that there is one extra step which should take to mix the react with asp.net webapi. that is ,edit the .cspoj file and put some extra code in it.
so , i created a new react with asp.net core app from visual studio template and opened the .csproj file and copied the stuff from there to my project .csproj. now it is working fine. here is link : here

CakePHP3 plugin test Class 'Cake\TestSuite\IntegrationTestCase' not found

I'm new using this framework and I've found a problem at the moment of testing a plugin.
PHP Fatal error: Class 'Cake\TestSuite\IntegrationTestCase' not found in /var/www/MyApp/plugins/MyPlugin/tests/TestCase/Controller/UsersControllerTest.php on line 11
Running the main application works well, but I have the same problem with all the test's classes of the plugin.
The head of the test's classes is similar to:
<?php
namespace MyPlugin\Test\TestCase\Controller;
use Cake\TestSuite\IntegrationTestCase;
use MyPlugin\Controller\UsersController;
class UsersControllerTest extends IntegrationTestCase
{
The phpunit.xml.dist of the plugin:
<?xml version="1.0" encoding="UTF-8"?><phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
</php>
<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="MyPlugin Test Suite">
<directory>./tests/TestCase</directory>
</testsuite>
</testsuites>
<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector"
file="../../vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
<!-- Prevent coverage reports from looking in tests and vendors -->
<filter>
<blacklist>
<directory suffix=".php">./vendor/</directory>
<directory suffix=".ctp">./vendor/</directory>
<directory suffix=".php">./tests/</directory>
<directory suffix=".ctp">./tests/</directory>
</blacklist>
</filter></phpunit>
And the composer.json:
{
"name": "your-name-here/MyPlugin",
"description": "MyPlugin plugin for CakePHP",
"type": "cakephp-plugin",
"require": {
"php": ">=5.4.16",
"cakephp/cakephp": "~3.0"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload": {
"psr-4": {
"MyPlugin\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"MyPlugin\\Test\\": "tests",
"Cake\\Test\\": "/var/www/MyApp/vendor/cakephp/cakephp/tests",
}
}
}
Thanks in advance!! ;)
Finally I got it fixed. In the phpunit.xml.dist file of the plugin, I made the bootstrap point to the one of the main application:
<?xml version="1.0" encoding="UTF-8"?><phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="../../config/bootstrap.php"
>
Also, in the same file, do not forget to make the listener in the same file point to the vendor of the main application, so that you don't have to re-install the entire CakePHP suite in your plugin:
<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector"
file="../../vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
It appears that by default, when baking a plugin, these two elements are not set the right way.
You need to run composer install in your plugin folder so that the CakePHP lib in installed under <your-plugin>/vendor/cakephp/cakephp
Since CakePHP 3.7 you should use
Application::addPlugin()
So in setUp() method it would be something like:
public function setUp()
{
parent::setUp();
(new \App\Application(APP . 'config' . DS))->addPlugin('YourPlugin');
//other options
}

FileTransfer is undefined in Cordova

I am working on Cordova tool in Visual studio.
I want to download files via given url, So for that I have installed File and FileTransfer plugins in application.
But it is giving me eror that,
FileTransfer is undefined.
I am writing it after device load.
I read somewhere that I need to activate requestFileSystem first, so I have also tried this code, but fail.
window.requestFileSystem(window.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
//create a dummy file to get paths
"dummy.html", { create: true, exclusive: false },
function gotFileEntry(fileEntry) {
var sPath = fileEntry.toURL().replace("dummy.html", "");
alert("Path = " + sPath);
//invoke the method to transfer files
var fileTransfer = new FileTransfer();
//remove the dummy file
fileEntry.remove();
//and now, we can download
fileTransfer.download("http://192.168.2.32:8080/MOBILEHRServices/leaveNotifications/getAttachments/2833739", sPath,
function (theFile) {
alert("Succ");
},
function (error) {
alert("Err");
}
);
},
fail);
},
fail);
Second code is,
alert("Start");
var fileTransfer = new FileTransfer();
fileTransfer.download("http://192.168.2.32:8080/MOBILEHRServices/leaveNotifications/getAttachments/2833739", sPath,
function (theFile) {
alert("Succ");
},
function (error) {
alert("Err");
}
);
In both above code FileTransfer() undefined...
Do I need to add anyrhing else too in solution. ?
My config file is,
in visual studio, We can add plugins via wizard...
File and FileTransfer plugins...
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps" id="io.cordova.down" version="1.0.0.0" xmlns="http://www.w3.org/ns/widgets">
<name>down</name>
<description>A blank project that uses Apache Cordova to help you build an app that targets multiple mobile platforms: Android, iOS, Windows, and Windows Phone.</description>
<author href="http://cordova.io" email="dev#cordova.apache.org">Apache Cordova Team </author>
<content src="index.html" />
<access origin="*" />
<preference name="SplashScreen" value="screen" />
<preference name="windows-target-version" value="8.0" />
<preference name="windows-phone-target-version" value="8.1" />
<vs:plugin name="org.apache.cordova.file" version="1.3.1" />
<vs:plugin name="org.apache.cordova.file-transfer" version="0.4.6" />
<vs:platformSpecificValues />
</widget>
Thank you.

Cassette.Nancy unbundled files returning 404

I've added Cassette.Nancy to an existing Nancy web project. This works fine when I set CassetteNancyStartup.OptimizeOutput = true; but when this is set to false I get 404 on the unbundled resources.
Here's my set up.
I'm using the following packages:
Cassette.Nancy version="2.1.1"
Cassette version="2.4.1"
Nancy version="0.22.2"
Nancy.Owin version="0.22.2"
Nancy.Viewengines.Razor version="0.22.2"
The files are like so:
Content
file1.css
file2.css
Scripts
script1.js
script2.js
CassetteBundleConfiguration:
public class CassetteBundleConfiguration : IConfiguration<BundleCollection>
{
public void Configure(BundleCollection bundles)
{
bundles.AddPerSubDirectory<StylesheetBundle>("Content");
bundles.Add<ScriptBundle>("Scripts");
}
}
in my _Layout.cshtml:
#{
Bundles.Reference("Content");
Bundles.Reference("Scripts");
}
#Bundles.RenderStylesheets()
#Bundles.RenderScripts()
And finally in Bootstrapper:
public Bootstrapper()
{
CassetteNancyStartup.OptimizeOutput = false;
}
Like I say this works fine when CassetteNancyStartup.OptimizeOutput is set to true but when false each of the resources return a 404 like this one:
GET http://localhost:10005/_cassette/asset/Content/file1.css?cf7a7edf515a8184a0c53ec498c583cc64bb0e63 404 (Not Found)
Any suggestions?
This issue was down to me not adding the Owin handler in the web.config. Adding this fixed it.
<system.webServer>
<handlers>
<add name="Owin" verb="*" path="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler, Microsoft.Owin.Host.SystemWeb" />
</handlers>
</system.webServer>

MirrorAPI - is there a way to detect if URL payload in OPEN_URI action is down or not successfully sent

Is there a way to detect if URL payload in OPEN_URI action is down or not successfully sent.
Especially if this it's a custom url protocol.
Example:
url payload: customprotocol://open
where customprotocol is defined in the manifest as in
Android native app, add in mainfest intent filter:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="customprotocol" />
</intent-filter>
Then launching native apk as mirror api action payload:
{
"id": "launchMe",
"action": "OPEN_URI",
"values": [
{
"displayName": "Open",
}
],
"payload": "customprotocol://open"
}
If customprotocol isn't launched, ie., if apk is not installed, is there a way to detect that?
(Technique from: )
https://plus.google.com/u/0/106035004831103549307/posts/E1XqxCoNBD7

Resources